From 58985894f6c66a381b8206ac7f991580b744da57 Mon Sep 17 00:00:00 2001
From: tracer-ysyx <tracer@ysyx.org>
Date: Wed, 13 Mar 2024 15:42:07 +0800
Subject: [PATCH] =?UTF-8?q?>=20compile=20NEMU=20ysyx=5F22040000=20?=
 =?UTF-8?q?=E6=9D=8E=E5=BF=83=E6=9D=A8=20Linux=20calcite=206.6.19=20#1-Nix?=
 =?UTF-8?q?OS=20SMP=20PREEMPT=5FDYNAMIC=20Fri=20Mar=20=201=2012:35:11=20UT?=
 =?UTF-8?q?C=202024=20x86=5F64=20GNU/Linux=20=2015:42:07=20=20up=20=20=205?=
 =?UTF-8?q?:18,=20=202=20users,=20=20load=20average:=200.69,=200.52,=200.4?=
 =?UTF-8?q?5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 flake.nix               | 1 +
 nemu/src/cpu/cpu-exec.c | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/flake.nix b/flake.nix
index 6656094..4492e28 100644
--- a/flake.nix
+++ b/flake.nix
@@ -65,6 +65,7 @@
         devShells.nemu = pkgs.mkShell {
           packages = with pkgs; [
             clang-tools
+            gdb
           ];
           inputsFrom = [
             self.packages.${system}.nemu
diff --git a/nemu/src/cpu/cpu-exec.c b/nemu/src/cpu/cpu-exec.c
index efb9557..c5696fa 100644
--- a/nemu/src/cpu/cpu-exec.c
+++ b/nemu/src/cpu/cpu-exec.c
@@ -75,6 +75,9 @@ static void exec_once(Decode *s, vaddr_t pc) {
 
 static void execute(uint64_t n) {
   Decode s;
+#ifdef CONFIG_ITRACE
+  memset(s.logbuf, 0, CONFIG_ITRACE_BUFFER * 128 * sizeof(char));
+#endif
   for (;n > 0; n --) {
     exec_once(&s, cpu.pc);
     g_nr_guest_inst ++;