diff --git a/src/main.c b/src/main.c index 8061645384a60f1b8cbabeae1d1913ffc49138c2..e77fd65f5d20909ad5b0253b1cf28637fcc14d95 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,6 @@ int init_monitor(int, char *[]); void ui_mainloop(int); +int goodtrap(void); int main(int argc, char *argv[]) { /* Initialize the monitor. */ @@ -8,5 +9,5 @@ int main(int argc, char *argv[]) { /* Receive commands from user. */ ui_mainloop(is_batch_mode); - return 0; + return !goodtrap(); } diff --git a/src/monitor/cpu-exec.c b/src/monitor/cpu-exec.c index e7d5cec7e9e7ecc046fcae0366a6836a52829b75..16801481f8d388eee5c5fbd4a9b034ce97317999 100644 --- a/src/monitor/cpu-exec.c +++ b/src/monitor/cpu-exec.c @@ -14,6 +14,10 @@ NEMUState nemu_state = {.state = NEMU_STOP}; +int goodtrap(void) { + return (nemu_state.state == NEMU_END && nemu_state.halt_ret == 0); +} + void interpret_rtl_exit(int state, vaddr_t halt_pc, uint32_t halt_ret) { nemu_state = (NEMUState) { .state = state, .halt_pc = halt_pc, .halt_ret = halt_ret }; }