diff --git a/Core/Debugger/WebSocket/CPUCoreSubscriber.cpp b/Core/Debugger/WebSocket/CPUCoreSubscriber.cpp index 2453675a33..3d42a46df3 100644 --- a/Core/Debugger/WebSocket/CPUCoreSubscriber.cpp +++ b/Core/Debugger/WebSocket/CPUCoreSubscriber.cpp @@ -17,6 +17,7 @@ #include "Common/StringUtils.h" #include "Core/Core.h" +#include "Core/CoreTiming.h" #include "Core/Debugger/WebSocket/CPUCoreSubscriber.h" #include "Core/Debugger/WebSocket/WebSocketUtils.h" #include "Core/MIPS/MIPS.h" @@ -79,10 +80,16 @@ void WebSocketCPUResume(DebuggerRequest &req) { // Response (same event name): // - stepping: boolean, CPU currently stepping. // - paused: boolean, CPU paused or not started yet. +// - pc: number value of PC register (inaccurate unless stepping.) +// - ticks: number of CPU cycles into emulation. void WebSocketCPUStatus(DebuggerRequest &req) { JsonWriter &json = req.Respond(); json.writeBool("stepping", PSP_IsInited() && Core_IsStepping() && coreState != CORE_POWERDOWN); json.writeBool("paused", GetUIState() != UISTATE_INGAME); + // Avoid NULL deference. + json.writeFloat("pc", PSP_IsInited() ? currentMIPS->pc : 0); + // A double ought to be good enough for a 156 day debug session. + json.writeFloat("ticks", PSP_IsInited() ? CoreTiming::GetTicks() : 0); } // Retrieve all regs and their values (cpu.getAllRegs) diff --git a/Core/Debugger/WebSocket/SteppingBroadcaster.cpp b/Core/Debugger/WebSocket/SteppingBroadcaster.cpp index 35b1a8c124..9b9cbf3200 100644 --- a/Core/Debugger/WebSocket/SteppingBroadcaster.cpp +++ b/Core/Debugger/WebSocket/SteppingBroadcaster.cpp @@ -16,17 +16,40 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include "Core/Core.h" +#include "Core/CoreTiming.h" #include "Core/Debugger/WebSocket/SteppingBroadcaster.h" #include "Core/Debugger/WebSocket/WebSocketUtils.h" +#include "Core/MIPS/MIPS.h" #include "Core/System.h" +struct CPUSteppingEvent { + operator std::string() { + JsonWriter j; + j.begin(); + j.writeString("event", "cpu.stepping"); + j.writeFloat("pc", currentMIPS->pc); + // A double ought to be good enough for a 156 day debug session. + j.writeFloat("ticks", CoreTiming::GetTicks()); + j.end(); + return j.str(); + } +}; + +// CPU has begun stepping (cpu.stepping) +// +// Sent unexpectedly with these properties: +// - pc: number value of PC register (inaccurate unless stepping.) +// - ticks: number of CPU cycles into emulation. + +// CPU has resumed from stepping (cpu.resume) +// +// Sent unexpectedly with no other properties. void SteppingBroadcaster::Broadcast(net::WebSocketServer *ws) { if (PSP_IsInited()) { int steppingCounter = Core_GetSteppingCounter(); // We ignore CORE_POWERDOWN as a stepping state. if (coreState == CORE_STEPPING && steppingCounter != lastCounter_) { - // TODO: Should send more data proactively. - ws->Send(R"({"event":"cpu.stepping"})"); + ws->Send(CPUSteppingEvent()); } else if (prevState_ == CORE_STEPPING && coreState != CORE_STEPPING && Core_IsActive()) { ws->Send(R"({"event":"cpu.resume"})"); }