Debugger: Prevent DebugBreakHelper from interfering with step operations done by the user

This commit is contained in:
Sour 2018-01-01 23:13:24 -05:00
parent baa71141ac
commit 8ad553688a
3 changed files with 19 additions and 5 deletions

View file

@ -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();
}

View file

@ -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<int, std::milli>(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;

View file

@ -104,6 +104,7 @@ private:
atomic<uint8_t> _lastInstruction;
atomic<bool> _stepOut;
atomic<int32_t> _stepOverAddr;
atomic<bool> _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);