Fix running when pc is at breakpoint. Fix issue when stepping through Ge-enqueuing functions.

This commit is contained in:
Henrik Rydgård 2024-12-08 15:00:11 +01:00
parent 50fadd1a4e
commit f74e7fb6f5

View file

@ -80,6 +80,7 @@ static std::set<CoreStopRequestFunc> 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<std::mutex> 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;