From 0531eb060a3028c028ffa7d4630b38749cb25c4a Mon Sep 17 00:00:00 2001 From: tracer-ysyx Date: Thu, 8 Feb 2024 19:25:40 +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.1.75=20#1-Nix?= =?UTF-8?q?OS=20SMP=20PREEMPT=5FDYNAMIC=20Thu=20Jan=2025=2023:27:52=20UTC?= =?UTF-8?q?=202024=20x86=5F64=20GNU/Linux=20=2019:25:40=20=20up=201=20day?= =?UTF-8?q?=20=205:01,=20=202=20users,=20=20load=20average:=201.09,=200.92?= =?UTF-8?q?,=200.80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nemu/src/cpu/cpu-exec.c | 6 +++--- nemu/src/monitor/sdb/watchpoint.c | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/nemu/src/cpu/cpu-exec.c b/nemu/src/cpu/cpu-exec.c index e91b4c8..6ad158a 100644 --- a/nemu/src/cpu/cpu-exec.c +++ b/nemu/src/cpu/cpu-exec.c @@ -31,7 +31,7 @@ static uint64_t g_timer = 0; // unit: us static bool g_print_step = false; void device_update(); -void wp_eval_all(); +bool wp_eval_all(); static void trace_and_difftest(Decode *_this, vaddr_t dnpc) { #ifdef CONFIG_ITRACE_COND @@ -78,6 +78,8 @@ static void execute(uint64_t n) { exec_once(&s, cpu.pc); g_nr_guest_inst ++; trace_and_difftest(&s, cpu.pc); + if (wp_eval_all()) break; + if (nemu_state.state != NEMU_RUNNING) break; IFDEF(CONFIG_DEVICE, device_update()); } @@ -114,8 +116,6 @@ void cpu_exec(uint64_t n) { uint64_t timer_end = get_time(); g_timer += timer_end - timer_start; - wp_eval_all(); - switch (nemu_state.state) { case NEMU_RUNNING: nemu_state.state = NEMU_STOP; break; diff --git a/nemu/src/monitor/sdb/watchpoint.c b/nemu/src/monitor/sdb/watchpoint.c index 5362ecd..aa48d78 100644 --- a/nemu/src/monitor/sdb/watchpoint.c +++ b/nemu/src/monitor/sdb/watchpoint.c @@ -136,12 +136,15 @@ static bool wp_check_change(WP* wp) { /* Check if watchpoint value changed after execution */ -void wp_eval_all() { +bool wp_eval_all() { WP *wp; + bool value_change = false; for (wp = head; wp != NULL; wp = wp->next) { int prev_val = wp->val; if (wp_check_change(wp)) { printf("Watchpoint %d: %s\n %u -> %u\n", wp->NO, wp->expr, prev_val, wp->val); + value_change = true; } } + return value_change; }