mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-13 06:20:26 +02:00
Debugger: Add cpu.evaluate method.
Probably useful for a bunch of things, really.
This commit is contained in:
1 parent
8a0e02e223
commit
f66738eac7
4 files changed
+91
-8
No files matched your search
@@ -31,6 +31,7 @@ void *WebSocketCPUCoreInit(DebuggerEventHandlerMap &map) {
|
||||
map["cpu.getAllRegs"] = &WebSocketCPUGetAllRegs;
|
||||
map["cpu.getReg"] = &WebSocketCPUGetReg;
|
||||
map["cpu.setReg"] = &WebSocketCPUSetReg;
|
||||
map["cpu.evaluate"] = &WebSocketCPUEvaluate;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@@ -334,3 +335,36 @@ void WebSocketCPUSetReg(DebuggerRequest &req) {
|
||||
json.writeFloat("uintValue", val);
|
||||
json.writeString("floatValue", RegValueAsFloat(val));
|
||||
}
|
||||
|
||||
// Evaluate an expression (cpu.evaluate)
|
||||
//
|
||||
// Parameters:
|
||||
// - expression: string containing labels, operators, regs, etc.
|
||||
//
|
||||
// Response (same event name):
|
||||
// - uintValue: value in register.
|
||||
// - floatValue: string showing float representation. May be "nan", "inf", or "-inf".
|
||||
void WebSocketCPUEvaluate(DebuggerRequest &req) {
|
||||
if (!currentDebugMIPS->isAlive()) {
|
||||
return req.Fail("CPU not started");
|
||||
}
|
||||
|
||||
std::string exp;
|
||||
if (!req.ParamString("expression", &exp)) {
|
||||
// Already sent error.
|
||||
return;
|
||||
}
|
||||
|
||||
u32 val;
|
||||
PostfixExpression postfix;
|
||||
if (!currentDebugMIPS->initExpression(exp.c_str(), postfix)) {
|
||||
return req.Fail(StringFromFormat("Could not parse expression syntax: %s", getExpressionError()));
|
||||
}
|
||||
if (!currentDebugMIPS->parseExpression(postfix, val)) {
|
||||
return req.Fail(StringFromFormat("Could not evaluate expression: %s", getExpressionError()));
|
||||
}
|
||||
|
||||
JsonWriter &json = req.Respond();
|
||||
json.writeFloat("uintValue", val);
|
||||
json.writeString("floatValue", RegValueAsFloat(val));
|
||||
}
|
||||
Reference in new issue
Block a user