diff --git a/src/isa/mips32/exec/system.c b/src/isa/mips32/exec/system.c index 99b70516d2a6881a631e4e0be638e46a07b18fd6..3dbda51de90bdc38ab41e87065b3a4bfc093545e 100644 --- a/src/isa/mips32/exec/system.c +++ b/src/isa/mips32/exec/system.c @@ -30,18 +30,16 @@ make_EHelper(mfc0) { #endif uint32_t val; - char *name; switch (id_dest->reg) { - case 12: val = cpu.status; name = "status"; break; - case 13: val = cpu.cause; name = "cause"; break; - case 14: val = cpu.epc; name = "epc"; break; + case 12: val = cpu.status; print_asm("mfc0 %s, status", id_src2->str); break; + case 13: val = cpu.cause; print_asm("mfc0 %s, cause", id_src2->str); break; + case 14: val = cpu.epc; print_asm("mfc0 %s, epc", id_src2->str); break; default: assert(0); } rtl_li(&s0, val); rtl_sr(id_src2->reg, &s0, 4); - print_asm("mfc0 %s, %s", id_src2->str, name); } make_EHelper(mtc0) { @@ -49,13 +47,11 @@ make_EHelper(mtc0) { difftest_skip_ref(); #endif - char *name; switch (id_dest->reg) { - case 12: cpu.status = id_src2->val; name = "status"; break; - case 13: cpu.cause = id_src2->val; name = "cause"; break; - case 14: cpu.epc = id_src2->val; name = "epc"; break; + case 12: cpu.status = id_src2->val; print_asm("mtc0 %s, status", id_src2->str); break; + case 13: cpu.cause = id_src2->val; print_asm("mtc0 %s, cause", id_src2->str); break; + case 14: cpu.epc = id_src2->val; print_asm("mtc0 %s, epc", id_src2->str); break; default: assert(0); } - print_asm("mtc0 %s, %s", id_src2->str, name); } diff --git a/src/monitor/cpu-exec.c b/src/monitor/cpu-exec.c index 3269b19efa05282cccf29658965c39177a65c734..31321096f2b8f7afc56fce2d5613d45bfaec75eb 100644 --- a/src/monitor/cpu-exec.c +++ b/src/monitor/cpu-exec.c @@ -1,5 +1,6 @@ #include "nemu.h" #include "monitor/monitor.h" +#include "monitor/watchpoint.h" /* The assembly code of instructions executed is only output to the screen * when the number of instructions executed is less than this value. @@ -37,6 +38,9 @@ void cpu_exec(uint64_t n) { bool print_flag = n < MAX_INSTR_TO_PRINT; for (; n > 0; n --) { +#ifdef DEBUG + vaddr_t temp_pc = cpu.pc; +#endif /* Execute one instruction, including instruction fetch, * instruction decode, and the actual execution. */ exec_wrapper(print_flag); @@ -44,6 +48,13 @@ void cpu_exec(uint64_t n) { #ifdef DEBUG /* TODO: check watchpoints here. */ + WP *wp = scan_watchpoint(); + if(wp != NULL) { + printf("\n\nHint watchpoint %d at address 0x%08x, expr = %s\n", wp->NO, temp_pc, wp->expr); + printf("old value = %#08x\nnew value = %#08x\n", wp->old_val, wp->new_val); + wp->old_val = wp->new_val; + return; + } #endif diff --git a/src/monitor/debug/expr.c b/src/monitor/debug/expr.c index 24eb9172e394fbe6a92f1cd4b7b7dcdccbfe98ec..2a9d0de7df8fc6a9381faf47c57cbe8fc0fba6cd 100644 --- a/src/monitor/debug/expr.c +++ b/src/monitor/debug/expr.c @@ -87,8 +87,8 @@ static bool make_token(char *e) { char *substr_start = e + position; int substr_len = pmatch.rm_eo; - Log("match rules[%d] = \"%s\" at position %d with len %d: %.*s", - i, rules[i].regex, position, substr_len, substr_len, substr_start); + //Log("match rules[%d] = \"%s\" at position %d with len %d: %.*s", + // i, rules[i].regex, position, substr_len, substr_len, substr_start); position += substr_len; diff --git a/src/monitor/diff-test/diff-test.c b/src/monitor/diff-test/diff-test.c index 72fc521d7db05fcd9155b6622faa568967390752..7343d3e0ca66d2e2aa2a89cfdd0da27d303a5b94 100644 --- a/src/monitor/diff-test/diff-test.c +++ b/src/monitor/diff-test/diff-test.c @@ -79,6 +79,8 @@ void difftest_step(vaddr_t pc) { // TODO: Check the registers state with QEMU. if (!isa_difftest_checkregs(&ref_r, pc)) { + extern void isa_reg_display(void); + isa_reg_display(); nemu_state.state = NEMU_ABORT; nemu_state.halt_pc = pc; }