diff --git a/Core/Core.cpp b/Core/Core.cpp index c93b93eee4..22266804f6 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -415,13 +415,18 @@ bool Core_Run(GraphicsContext *ctx) { // Free-threaded (hm, possibly except tracing). void Core_Break(const char *reason, u32 relatedAddress) { // Stop the tracer - mipsTracer.stop_tracing(); - { std::lock_guard lock(g_stepMutex); + if (!g_stepCommand.empty()) { + // Already broke. + ERROR_LOG(Log::CPU, "Core_Break called with a break already in progress: %s", g_stepCommand.reason); + return; + } + mipsTracer.stop_tracing(); + g_stepCommand.reason = reason; + g_stepCommand.relatedAddr = relatedAddress; steppingCounter++; _assert_msg_(reason != nullptr, "No reason specified for break"); - Core_UpdateState(CORE_STEPPING); } System_Notify(SystemNotification::DEBUG_MODE_CHANGE); diff --git a/Core/Debugger/WebSocket/SteppingBroadcaster.cpp b/Core/Debugger/WebSocket/SteppingBroadcaster.cpp index 6e7e4aa71e..bbb17862fa 100644 --- a/Core/Debugger/WebSocket/SteppingBroadcaster.cpp +++ b/Core/Debugger/WebSocket/SteppingBroadcaster.cpp @@ -33,8 +33,10 @@ struct CPUSteppingEvent { j.writeUint("pc", currentMIPS->pc); // A double ought to be good enough for a 156 day debug session. j.writeFloat("ticks", CoreTiming::GetTicks()); - j.writeString("reason", reason_.reason); - j.writeUint("relatedAddress", reason_.relatedAddress); + if (reason_.reason) { + j.writeString("reason", reason_.reason); + j.writeUint("relatedAddress", reason_.relatedAddress); + } j.end(); return j.str(); } diff --git a/Core/PSPLoaders.cpp b/Core/PSPLoaders.cpp index c1e59d2f3b..57c8969d89 100644 --- a/Core/PSPLoaders.cpp +++ b/Core/PSPLoaders.cpp @@ -17,6 +17,7 @@ #include +#include "Core/Core.h" #include "Common/Data/Encoding/Utf8.h" #include "Common/Thread/ThreadUtil.h" #include "Common/System/Request.h" @@ -324,7 +325,11 @@ bool Load_PSP_ISO(FileLoader *fileLoader, std::string *error_string) { // TODO: We can't use the initial error_string pointer. bool success = __KernelLoadExec(bootpath.c_str(), 0, &PSP_CoreParameter().errorString); if (success && coreState == CORE_POWERUP) { - coreState = PSP_CoreParameter().startBreak ? CORE_STEPPING : CORE_RUNNING; + if (PSP_CoreParameter().startBreak) { + Core_Break("start-break"); + } else { + coreState = CORE_RUNNING; + } } else { coreState = CORE_BOOT_ERROR; // TODO: This is a crummy way to communicate the error... @@ -483,7 +488,11 @@ bool Load_PSP_ELF_PBP(FileLoader *fileLoader, std::string *error_string) { bool success = __KernelLoadExec(finalName.c_str(), 0, &PSP_CoreParameter().errorString); if (success && coreState == CORE_POWERUP) { - coreState = PSP_CoreParameter().startBreak ? CORE_STEPPING : CORE_RUNNING; + if (PSP_CoreParameter().startBreak) { + Core_Break("start-break"); + } else { + coreState = CORE_RUNNING; + } } else { coreState = CORE_BOOT_ERROR; // TODO: This is a crummy way to communicate the error... @@ -509,7 +518,11 @@ bool Load_PSP_GE_Dump(FileLoader *fileLoader, std::string *error_string) { bool success = __KernelLoadGEDump("disc0:/data.ppdmp", &PSP_CoreParameter().errorString); if (success && coreState == CORE_POWERUP) { - coreState = PSP_CoreParameter().startBreak ? CORE_STEPPING : CORE_RUNNING; + if (PSP_CoreParameter().startBreak) { + Core_Break("start-break"); + } else { + coreState = CORE_RUNNING; + } } else { coreState = CORE_BOOT_ERROR; // TODO: This is a crummy way to communicate the error...