Merge remote-tracking branch 'origin/priv-1.10' into HEAD
[riscv-isa-sim.git] / riscv / execute.cc
index 1b53ccf7c3e4eeff9dfcf426f3b3024d5f354d99..7734ca2749d6756ca2270e6c359a3d28db712ec9 100644 (file)
@@ -63,16 +63,11 @@ bool processor_t::slow_path()
 void processor_t::step(size_t n)
 {
   if (state.dcsr.cause == DCSR_CAUSE_NONE) {
-    // TODO: get_interrupt() isn't super fast. Does that matter?
-    if (sim->debug_module.get_interrupt(id)) {
+    if (halt_request) {
       enter_debug_mode(DCSR_CAUSE_DEBUGINT);
     } else if (state.dcsr.halt) {
       enter_debug_mode(DCSR_CAUSE_HALT);
     }
-  } else {
-    // In Debug Mode, just do 11 steps at a time. Otherwise we're going to be
-    // spinning the rest of the time anyway.
-    n = std::min(n, (size_t) 11);
   }
 
   while (n > 0) {
@@ -120,6 +115,13 @@ void processor_t::step(size_t n)
             // enter_debug_mode changed state.pc, so we can't just continue.
             break;
           }
+
+          if (unlikely(state.pc >= DEBUG_ROM_ENTRY &&
+                state.pc < DEBUG_ROM_ENTRY + DEBUG_ROM_ENTRY_SIZE)) {
+            // We're spinning waiting for the debugger to tell us something.
+            // Let's go talk to the debugger.
+            return;
+          }
         }
       }
       else while (instret < n)