8000 Debugger: Add API to scan memory for funcs by unknownbrackets · Pull Request #16121 · hrydgard/ppsspp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Debugger: Add API to scan memory for funcs #16121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Core/Debugger/WebSocket/DisasmSubscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ void WebSocketDisasmState::Disasm(DebuggerRequest &req) {
json.pop();
}

// Search disassembly for some text (cpu.searchDisasm)
// Search disassembly for some text (memory.searchDisasm)
//
// Parameters:
// - thread: optional number indicating the thread id (may not affect search much.)
Expand Down Expand Up @@ -461,7 +461,7 @@ void WebSocketDisasmState::SearchDisasm(DebuggerRequest &req) {
json.writeNull("address");
}

// Assemble an instruction (cpu.assemble)
// Assemble an instruction (memory.assemble)
//
// Parameters:
// - address: number indicating the address to write to.
Expand Down
31 changes: 31 additions & 0 deletions Core/Debugger/WebSocket/HLESubscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "Core/Debugger/SymbolMap.h"
#include "Core/Debugger/WebSocket/HLESubscriber.h"
#include "Core/Debugger/WebSocket/WebSocketUtils.h"
#include "Core/MemMap.h"
#include "Core/MIPS/MIPSAnalyst.h"
#include "Core/MIPS/MIPSDebugInterface.h"
#include "Core/MIPS/MIPSStackWalk.h"
Expand All @@ -36,6 +37,7 @@ DebuggerSubscriber *WebSocketHLEInit(DebuggerEventHandlerMap &map) {
map["hle.func.add"] = &WebSocketHLEFuncAdd;
map["hle.func.remove"] = &WebSocketHLEFuncRemove;
map["hle.func.rename"] = &WebSocketHLEFuncRename;
map["hle.func.scan"] = &WebSocketHLEFuncScan;
map["hle.module.list"] = &WebSocketHLEModuleList;
map["hle.backtrace"] = &WebSocketHLEBacktrace;

Expand Down Expand Up @@ -403,6 +405,35 @@ void WebSocketHLEFuncRename(DebuggerRequest &req) {
json.writeString("name", name);
}

// Auto-detect functions in a memory range (hle.func.scan)
//
// Parameters:
// - address: unsigned integer address within function to rename.
// - size: unsigned integer size in bytes for scan.
//
// Response (same event name) with no extra data.
void WebSocketHLEFuncScan(DebuggerRequest &req) {
if (!g_symbolMap)
return req.Fail("CPU not active");
if (!Core_IsStepping())
return req.Fail("CPU currently running (cpu.stepping first)");

u32 addr;
if (!req.ParamU32("address", &addr))
return;
u32 size;
if (!req.ParamU32("size", &size))
return;

if (!Memory::IsValidRange(addr, size))
return req.Fail("Address or size outside valid memory");

bool insertSymbols = MIPSAnalyst::ScanForFunctions(addr, addr + size, true);
MIPSAnalyst::FinalizeScan(insertSymbols);

req.Respond();
}

// List all known user modules (hle.module.list)
//
// No parameters.
Expand Down
1 change: 1 addition & 0 deletions Core/Debugger/WebSocket/HLESubscriber.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ void WebSocketHLEFuncList(DebuggerRequest &req);
void WebSocketHLEFuncAdd(DebuggerRequest &req);
void WebSocketHLEFuncRemove(DebuggerRequest &req);
void WebSocketHLEFuncRename(DebuggerRequest &req);
void WebSocketHLEFuncScan(DebuggerRequest &req);
void WebSocketHLEModuleList(DebuggerRequest &req);
void WebSocketHLEBacktrace(DebuggerRequest &req);
0