Permalink
Browse files

Debugger: Allow pinging current status.

Helps especially when reconnecting.
  • Loading branch information...
unknownbrackets committed Apr 20, 2018
1 parent c44d8db commit d67a1d4a3aac40f31a40b4d5aa6599ca7367040b
Showing with 20 additions and 0 deletions.
  1. +19 −0 Core/Debugger/WebSocket/CPUCoreSubscriber.cpp
  2. +1 −0 Core/Debugger/WebSocket/CPUCoreSubscriber.h
@@ -26,6 +26,7 @@ void *WebSocketCPUCoreInit(DebuggerEventHandlerMap &map) {
// No need to bind or alloc state, these are all global.
map["cpu.stepping"] = &WebSocketCPUStepping;
map["cpu.resume"] = &WebSocketCPUResume;
map["cpu.status"] = &WebSocketCPUStatus;
map["cpu.getAllRegs"] = &WebSocketCPUGetAllRegs;
map["cpu.getReg"] = &WebSocketCPUGetReg;
map["cpu.setReg"] = &WebSocketCPUSetReg;
@@ -71,6 +72,19 @@ void WebSocketCPUResume(DebuggerRequest &req) {
Core_EnableStepping(false);
}
// Request the current CPU status (cpu.status)
//
// No parameters.
//
// Response (same event name):
// - stepping: boolean, CPU currently stepping.
// - paused: boolean, CPU paused or not started yet.
void WebSocketCPUStatus(DebuggerRequest &req) {
JsonWriter &json = req.Respond();
json.writeBool("stepping", PSP_IsInited() && Core_IsStepping() && coreState != CORE_POWERDOWN);
json.writeBool("paused", GetUIState() != UISTATE_INGAME);
}
// Retrieve all regs and their values (cpu.getAllRegs)
//
// No parameters.
@@ -283,7 +297,12 @@ void WebSocketCPUSetReg(DebuggerRequest &req) {
int cat, reg;
switch (ValidateCatReg(req, &cat, &reg)) {
case DebuggerRegType::NORMAL:
if (cat == 0 && reg == 0 && val != 0) {
return req.Fail("Cannot change reg zero");
}
currentDebugMIPS->SetRegValue(cat, reg, val);
// In case part of it was ignored (e.g. flags reg.)
val = currentDebugMIPS->GetRegValue(cat, reg);
break;
case DebuggerRegType::PC:
@@ -23,6 +23,7 @@ void *WebSocketCPUCoreInit(DebuggerEventHandlerMap &map);
void WebSocketCPUStepping(DebuggerRequest &req);
void WebSocketCPUResume(DebuggerRequest &req);
void WebSocketCPUStatus(DebuggerRequest &req);
void WebSocketCPUGetAllRegs(DebuggerRequest &req);
void WebSocketCPUGetReg(DebuggerRequest &req);
void WebSocketCPUSetReg(DebuggerRequest &req);

0 comments on commit d67a1d4

Please sign in to comment.