From f74e7fb6f5ac852d2cb87246901072f0b499260a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 8 Dec 2024 15:00:11 +0100 Subject: [PATCH] Fix running when pc is at breakpoint. Fix issue when stepping through Ge-enqueuing functions. --- Core/Core.cpp | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/Core/Core.cpp b/Core/Core.cpp index 61bf1bcabe..9e3c92318b 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -80,6 +80,7 @@ static std::set stopFuncs; // This can be read and written from ANYWHERE. volatile CoreState coreState = CORE_STEPPING_CPU; +CoreState preGeCoreState = CORE_BOOT_ERROR; // If true, core state has been changed, but JIT has probably not noticed yet. volatile bool coreStatePending = false; @@ -184,18 +185,18 @@ void Core_RunLoopUntil(u64 globalticks) { case DLResult::Error: // We should elegantly report the error, or I guess ignore it. hleFinishSyscallAfterGe(); - coreState = CORE_RUNNING_CPU; + coreState = preGeCoreState; break; case DLResult::Stall: case DLResult::Done: // Done executing for now hleFinishSyscallAfterGe(); - coreState = CORE_RUNNING_CPU; + coreState = preGeCoreState; break; default: _dbg_assert_(false); hleFinishSyscallAfterGe(); - coreState = CORE_RUNNING_CPU; + coreState = preGeCoreState; break; } break; @@ -203,6 +204,13 @@ void Core_RunLoopUntil(u64 globalticks) { } } +// Should only be called from GPUCommon functions (called from sceGe functions). +void Core_SwitchToGe() { + // TODO: This should be an atomic exchange. Or we add bitflags into coreState. + preGeCoreState = coreState; + coreState = CORE_RUNNING_GE; +} + bool Core_RequestCPUStep(CPUStepType type, int stepSize) { std::lock_guard guard(g_stepMutex); if (g_cpuStepCommand.type != CPUStepType::None) { @@ -291,8 +299,6 @@ static void Core_PerformCPUStep(MIPSDebugInterface *cpu, CPUStepType stepType, i u32 breakpointAddress = frames[1].pc; - // If the current PC is on a breakpoint, the user doesn't want to do nothing. - g_breakpoints.SetSkipFirst(currentMIPS->pc); g_breakpoints.AddBreakPoint(breakpointAddress, true); Core_Resume(); break; @@ -303,15 +309,6 @@ static void Core_PerformCPUStep(MIPSDebugInterface *cpu, CPUStepType stepType, i } } -static void Core_PerformGeStep(CPUStepType stepType) { - // TODO -} - -// Should only be called from GPUCommon functions (called from sceGe functions). -void Core_SwitchToGe() { - coreState = CORE_RUNNING_GE; -} - static void Core_ProcessStepping(MIPSDebugInterface *cpu) { Core_StateProcessed(); @@ -399,6 +396,8 @@ void Core_Break(const char *reason, u32 relatedAddress) { // Free-threaded (or at least should be) void Core_Resume() { + // If the current PC is on a breakpoint, the user doesn't want to do nothing. + g_breakpoints.SetSkipFirst(currentMIPS->pc); // Handle resuming from GE. if (coreState == CORE_STEPPING_GE) { coreState = CORE_RUNNING_GE;