From 71e855a822b5fbd08fbdd02a78cdb0ea85398ea4 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 13 Feb 2022 10:22:59 -0800 Subject: [PATCH] GE Debugger: Track last gstate on stepping. --- GPU/Debugger/Stepping.cpp | 36 ++++++++++++++++++++++++++---------- GPU/Debugger/Stepping.h | 3 +++ 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/GPU/Debugger/Stepping.cpp b/GPU/Debugger/Stepping.cpp index ea3ce03715..2b750235a7 100644 --- a/GPU/Debugger/Stepping.cpp +++ b/GPU/Debugger/Stepping.cpp @@ -65,6 +65,8 @@ static GPUDebugBuffer bufferClut; static int bufferLevel; static u32 pauseSetCmdValue; +static GPUgstate lastGState; + static void SetPauseAction(PauseAction act, bool waitComplete = true) { pauseLock.lock(); std::unique_lock guard(actionLock); @@ -133,6 +135,22 @@ static void RunPauseAction() { pauseAction = PAUSE_BREAK; } +static void StartStepping() { + if (lastGState.cmdmem[1] == 0) { + lastGState = gstate; + // Play it safe so we don't keep resetting. + lastGState.cmdmem[1] |= 0x01000000; + } + gpuDebug->NotifySteppingEnter(); + isStepping = true; +} + +static void StopStepping() { + gpuDebug->NotifySteppingExit(); + lastGState = gstate; + isStepping = false; +} + bool SingleStep() { std::unique_lock guard(pauseLock); if (coreState != CORE_RUNNING && coreState != CORE_NEXTFRAME && coreState != CORE_STEPPING) { @@ -147,13 +165,9 @@ bool SingleStep() { return false; } - gpuDebug->NotifySteppingEnter(); - isStepping = true; - + StartStepping(); RunPauseAction(); - - gpuDebug->NotifySteppingExit(); - isStepping = false; + StopStepping(); return true; } @@ -171,13 +185,12 @@ bool EnterStepping() { return false; } - gpuDebug->NotifySteppingEnter(); + StartStepping(); // Just to be sure. if (pauseAction == PAUSE_CONTINUE) { pauseAction = PAUSE_BREAK; } - isStepping = true; stepCounter++; do { @@ -185,8 +198,7 @@ bool EnterStepping() { pauseWait.wait(guard); } while (pauseAction != PAUSE_CONTINUE); - gpuDebug->NotifySteppingExit(); - isStepping = false; + StopStepping(); return true; } @@ -263,4 +275,8 @@ void ForceUnpause() { actionWait.notify_all(); } +GPUgstate LastState() { + return lastGState; +} + } // namespace diff --git a/GPU/Debugger/Stepping.h b/GPU/Debugger/Stepping.h index af93743eb3..35409c03b9 100644 --- a/GPU/Debugger/Stepping.h +++ b/GPU/Debugger/Stepping.h @@ -22,6 +22,7 @@ #include "Common/CommonTypes.h" #include "Core/Core.h" #include "GPU/Common/GPUDebugInterface.h" +#include "GPU/GPUState.h" namespace GPUStepping { // Should be called from the emu thread. @@ -42,4 +43,6 @@ namespace GPUStepping { void ResumeFromStepping(); void ForceUnpause(); + + GPUgstate LastState(); };