From c9ad69a32dcc4edc9531c5385a55a74819019416 Mon Sep 17 00:00:00 2001 From: xinyangli Date: Thu, 25 Jul 2024 17:56:30 +0800 Subject: [PATCH] nemu: break before executing instruction --- nemu/src/cpu/cpu-exec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nemu/src/cpu/cpu-exec.c b/nemu/src/cpu/cpu-exec.c index 583013e..49d2b6f 100644 --- a/nemu/src/cpu/cpu-exec.c +++ b/nemu/src/cpu/cpu-exec.c @@ -158,8 +158,6 @@ breakpoint_t *cpu_exec_with_bp(uint64_t n, breakpoint_t *bp, size_t len) { static Decode s; nemu_state.state = NEMU_RUNNING; do { - exec_once(&s, cpu.pc); - g_nr_guest_inst++; for (int i = 0; i < len; i++) { size_t addr = bp[i].addr; bp_type_t bptype = bp[i].type; @@ -176,6 +174,8 @@ breakpoint_t *cpu_exec_with_bp(uint64_t n, breakpoint_t *bp, size_t len) { return bp + i; } } + exec_once(&s, cpu.pc); + g_nr_guest_inst++; if (nemu_state.state != NEMU_RUNNING) return NULL; } while (--n);