diff --git a/Core/DebugBreakHelper.h b/Core/DebugBreakHelper.h index e2a10bcc..c2673821 100644 --- a/Core/DebugBreakHelper.h +++ b/Core/DebugBreakHelper.h @@ -21,7 +21,7 @@ public: //Only attempt to break if this is done in a thread other than the main emulation thread debugger->PreventResume(); if(!debugger->IsExecutionStopped()) { - debugger->Step(1); + debugger->Break(); while(!debugger->IsExecutionStopped()) {} _needResume = true; } @@ -32,7 +32,7 @@ public: { if(!_isEmulationThread) { if(_needResume) { - _debugger->Run(); + _debugger->ResumeFromBreak(); } _debugger->AllowResume(); } diff --git a/Core/Debugger.cpp b/Core/Debugger.cpp index 1e093a67..fd3f44dd 100644 --- a/Core/Debugger.cpp +++ b/Core/Debugger.cpp @@ -589,10 +589,10 @@ bool Debugger::SleepUntilResume() stepCount = _stepCount.load(); } - if(stepCount == 0 && !_stopFlag && _suspendCount == 0) { + if((stepCount == 0 || _breakRequested) && !_stopFlag && _suspendCount == 0) { //Break auto lock = _breakLock.AcquireSafe(); - + if(_preventResume == 0) { SoundMixer::StopAudio(); MessageManager::SendNotification(ConsoleNotificationType::CodeBreak); @@ -604,7 +604,7 @@ bool Debugger::SleepUntilResume() } _executionStopped = true; - while((stepCount == 0 && !_stopFlag && _suspendCount == 0) || _preventResume > 0) { + while(((stepCount == 0 || _breakRequested) && !_stopFlag && _suspendCount == 0) || _preventResume > 0) { std::this_thread::sleep_for(std::chrono::duration(10)); stepCount = _stepCount.load(); } @@ -665,6 +665,16 @@ void Debugger::SetState(DebugState state) } } +void Debugger::Break() +{ + _breakRequested = true; +} + +void Debugger::ResumeFromBreak() +{ + _breakRequested = false; +} + void Debugger::PpuStep(uint32_t count) { _ppuStepCount = count; diff --git a/Core/Debugger.h b/Core/Debugger.h index d393602b..3f1e112a 100644 --- a/Core/Debugger.h +++ b/Core/Debugger.h @@ -104,6 +104,7 @@ private: atomic _lastInstruction; atomic _stepOut; atomic _stepOverAddr; + atomic _breakRequested; int32_t _ppuViewerScanline; int32_t _ppuViewerCycle; @@ -160,6 +161,9 @@ public: void Suspend(); void Resume(); + void Break(); + void ResumeFromBreak(); + void PpuStep(uint32_t count = 1); void Step(uint32_t count = 1); void StepCycles(uint32_t cycleCount = 1);