From 4ce3fdfcb202285689f36eecaf52fae748916a94 Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Sat, 2 May 2020 04:53:03 +0100 Subject: [PATCH] Fix up debugger stepping --- pcsx2/Interpreter.cpp | 2 +- pcsx2/System/SysThreadBase.cpp | 15 +++++++++++++++ pcsx2/System/SysThreads.h | 1 + pcsx2/gui/Debugger/DisassemblyDialog.cpp | 9 +++++---- pcsx2/x86/ix86-32/iR5900-32.cpp | 4 ++-- 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/pcsx2/Interpreter.cpp b/pcsx2/Interpreter.cpp index a2facc0b76..891adbb019 100644 --- a/pcsx2/Interpreter.cpp +++ b/pcsx2/Interpreter.cpp @@ -60,7 +60,7 @@ void intBreakpoint(bool memcheck) } CBreakPoints::SetBreakpointTriggered(true); - GetCoreThread().PauseSelf(); + GetCoreThread().PauseSelfDebug(); throw Exception::ExitCpuExecute(); } diff --git a/pcsx2/System/SysThreadBase.cpp b/pcsx2/System/SysThreadBase.cpp index 007c2ed517..6b179d81b8 100644 --- a/pcsx2/System/SysThreadBase.cpp +++ b/pcsx2/System/SysThreadBase.cpp @@ -168,6 +168,21 @@ void SysThreadBase::PauseSelf() } } +void SysThreadBase::PauseSelfDebug() +{ + if (!IsSelf() || !IsRunning()) return; + + { + ScopedLock locker(m_ExecModeMutex); + + if (m_ExecMode == ExecMode_Opened) + m_ExecMode = ExecMode_Pausing; + + OnPauseDebug(); + m_sem_event.Post(); + } +} + // Resumes the core execution state, or does nothing is the core is already running. If // settings were changed, resets will be performed as needed and emulation state resumed from // memory savestates. diff --git a/pcsx2/System/SysThreads.h b/pcsx2/System/SysThreads.h index e045f80bfb..6ddf09fadb 100644 --- a/pcsx2/System/SysThreads.h +++ b/pcsx2/System/SysThreads.h @@ -114,6 +114,7 @@ public: virtual void Resume(); virtual void Pause(bool debug = false); virtual void PauseSelf(); + virtual void PauseSelfDebug(); protected: virtual void OnStart(); diff --git a/pcsx2/gui/Debugger/DisassemblyDialog.cpp b/pcsx2/gui/Debugger/DisassemblyDialog.cpp index 3ce31cd409..bde09c022d 100644 --- a/pcsx2/gui/Debugger/DisassemblyDialog.cpp +++ b/pcsx2/gui/Debugger/DisassemblyDialog.cpp @@ -611,10 +611,11 @@ void DisassemblyDialog::setDebugMode(bool debugMode, bool switchPC) if (debugMode) { - { - wxBusyInfo wait("Please wait, Reading ELF functions"); - reset(); - } + if (!CBreakPoints::GetBreakpointTriggered()) + { + wxBusyInfo wait("Please wait, Reading ELF functions"); + reset(); + } CBreakPoints::ClearTemporaryBreakPoints(); breakRunButton->SetLabel(L"Run"); diff --git a/pcsx2/x86/ix86-32/iR5900-32.cpp b/pcsx2/x86/ix86-32/iR5900-32.cpp index 8d23213c59..7a01f6ed51 100644 --- a/pcsx2/x86/ix86-32/iR5900-32.cpp +++ b/pcsx2/x86/ix86-32/iR5900-32.cpp @@ -1148,7 +1148,7 @@ void dynarecCheckBreakpoint() return; CBreakPoints::SetBreakpointTriggered(true); - GetCoreThread().PauseSelf(); + GetCoreThread().PauseSelfDebug(); recExitExecution(); } @@ -1159,7 +1159,7 @@ void dynarecMemcheck() return; CBreakPoints::SetBreakpointTriggered(true); - GetCoreThread().PauseSelf(); + GetCoreThread().PauseSelfDebug(); recExitExecution(); }