When gdb connects, jump to Debug ROM and segfault.
[riscv-isa-sim.git] / riscv / execute.cc
index 45205b3d2ca1681f30bcc8740e8590356969d390..1796c3884ba2a2d2761ddd7512dada25c7cd4b92 100644 (file)
@@ -53,9 +53,11 @@ static reg_t execute_insn(processor_t* p, reg_t pc, insn_fetch_t fetch)
 // fetch/decode/execute loop
 void processor_t::step(size_t n)
 {
-  // TODO: We should really not call this function at all when halted, to avoid
-  // burning CPU.
-  while (run && !halted && n > 0) {
+  if (state.dcsr.debugint && state.dcsr.cause == DCSR_CAUSE_NONE) {
+    enter_debug_mode(DCSR_CAUSE_DEBUGINT);
+  }
+
+  while (n > 0) {
     size_t instret = 0;
     reg_t pc = state.pc;
     mmu_t* _mmu = mmu;