Permalink
Browse files

Debugger: Add cpu.stepping and cpu.resume.

  • Loading branch information...
unknownbrackets committed Apr 15, 2018
1 parent a4044fd commit a3419946222624b0addc5b3296643460645d4d6b
@@ -24,6 +24,8 @@
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.getAllRegs"] = &WebSocketCPUGetAllRegs;
map["cpu.getReg"] = &WebSocketCPUGetReg;
map["cpu.setReg"] = &WebSocketCPUSetReg;
@@ -39,6 +41,36 @@ static std::string RegValueAsFloat(uint32_t u) {
return StringFromFormat("%f", bits.f);
}
// Begin stepping and pause the CPU (cpu.stepping)
//
// No parameters.
//
// No immediate response. Once CPU is stepping, a "cpu.stepping" event will be sent.
void WebSocketCPUStepping(DebuggerRequest &req) {
if (!currentDebugMIPS->isAlive()) {
return req.Fail("CPU not started");
}
if (!Core_IsStepping() && Core_IsActive()) {
Core_EnableStepping(true);
}
}
// Stop stepping and resume the CPU (cpu.resume)
//
// No parameters.
//
// No immediate response. Once CPU is stepping, a "cpu.resume" event will be sent.
void WebSocketCPUResume(DebuggerRequest &req) {
if (!currentDebugMIPS->isAlive()) {
return req.Fail("CPU not started");
}
if (!Core_IsStepping() || coreState == CORE_POWERDOWN) {
return req.Fail("CPU not stepping");
}
Core_EnableStepping(false);
}
// Retrieve all regs and their values (cpu.getAllRegs)
//
// No parameters.
@@ -21,6 +21,8 @@
void *WebSocketCPUCoreInit(DebuggerEventHandlerMap &map);
void WebSocketCPUStepping(DebuggerRequest &req);
void WebSocketCPUResume(DebuggerRequest &req);
void WebSocketCPUGetAllRegs(DebuggerRequest &req);
void WebSocketCPUGetReg(DebuggerRequest &req);
void WebSocketCPUSetReg(DebuggerRequest &req);
@@ -22,11 +22,14 @@
void SteppingBroadcaster::Broadcast(net::WebSocketServer *ws) {
// TODO: This is somewhat primitive. It'd be nice to register a callback with Core instead?
if (coreState != prevState_) {
if (Core_IsStepping() && PSP_IsInited()) {
if (coreState != prevState_ && PSP_IsInited()) {
// We ignore CORE_POWERDOWN.
if (coreState == CORE_STEPPING) {
// TODO: Should send more data proactively.
ws->Send(R"({"event":"cpu.stepping"})");
} else if (prevState_ == CORE_STEPPING && Core_IsActive()) {
ws->Send(R"({"event":"cpu.resume"})");
}
prevState_ = coreState;
}
prevState_ = coreState;
}

0 comments on commit a341994

Please sign in to comment.