From 0e848d2f4376726e74bbf0cecb97ca15e28ca675 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Tue, 21 Feb 2017 19:32:24 -0800 Subject: [PATCH] Don't waste time spinning in place in debug mode --- riscv/execute.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/riscv/execute.cc b/riscv/execute.cc index eb9fe4b..1e63cf0 100644 --- a/riscv/execute.cc +++ b/riscv/execute.cc @@ -69,10 +69,6 @@ void processor_t::step(size_t n) } 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 +116,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) -- 2.30.2