mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-10 21:16:24 +02:00
Debugger: Provide memory mapping ranges.
Most of these are entirely static, but introspection is good for APIs.
This commit is contained in:
1 parent
a0c1320aec
commit
124774fecb
2 files changed
+79
-10
No files matched your search
@@ -18,6 +18,7 @@
|
||||
#include "Core/Debugger/MemBlockInfo.h"
|
||||
#include "Core/Debugger/WebSocket/MemoryInfoSubscriber.h"
|
||||
#include "Core/Debugger/WebSocket/WebSocketUtils.h"
|
||||
#include "Core/MemMap.h"
|
||||
|
||||
class WebSocketMemoryInfoState : public DebuggerSubscriber {
|
||||
public:
|
||||
@@ -27,6 +28,7 @@ public:
|
||||
UpdateOverride(false);
|
||||
}
|
||||
|
||||
void Mapping(DebuggerRequest &req);
|
||||
void Config(DebuggerRequest &req);
|
||||
|
||||
protected:
|
||||
@@ -37,6 +39,7 @@ protected:
|
||||
|
||||
DebuggerSubscriber *WebSocketMemoryInfoInit(DebuggerEventHandlerMap &map) {
|
||||
auto p = new WebSocketMemoryInfoState();
|
||||
map["memory.mapping"] = std::bind(&WebSocketMemoryInfoState::Mapping, p, std::placeholders::_1);
|
||||
map["memory.info.config"] = std::bind(&WebSocketMemoryInfoState::Config, p, std::placeholders::_1);
|
||||
|
||||
return p;
|
||||
@@ -50,6 +53,72 @@ void WebSocketMemoryInfoState::UpdateOverride(bool flag) {
|
||||
detailOverride_ = flag;
|
||||
}
|
||||
|
||||
// List memory map data (memory.mapping)
|
||||
//
|
||||
// No parameters.
|
||||
//
|
||||
// Response (same event name):
|
||||
// - ranges: array of objects:
|
||||
// - type: one of "ram", "vram", "sram".
|
||||
// - subtype: "primary" or "mirror".
|
||||
// - name: string, friendly name.
|
||||
// - address: number, start address of range.
|
||||
// - size: number, in bytes.
|
||||
//
|
||||
// Note: Even if you set false, may stay enabled if set by user or another debug session.
|
||||
void WebSocketMemoryInfoState::Mapping(DebuggerRequest &req) {
|
||||
struct MemRange {
|
||||
const char *type;
|
||||
const char *subtype;
|
||||
const char *name;
|
||||
const uint32_t address;
|
||||
const uint32_t size;
|
||||
};
|
||||
constexpr uint32_t kernelMemorySize = PSP_GetKernelMemoryEnd() - PSP_GetKernelMemoryBase();
|
||||
constexpr uint32_t volatileMemorySize = PSP_GetVolatileMemoryEnd() - PSP_GetVolatileMemoryStart();
|
||||
static constexpr MemRange ranges[] = {
|
||||
{ "sram", "primary", "Scratchpad", PSP_GetScratchpadMemoryBase(), Memory::SCRATCHPAD_SIZE },
|
||||
{ "vram", "primary", "VRAM", PSP_GetVidMemBase(), Memory::VRAM_SIZE },
|
||||
{ "vram", "mirror", "VRAM (Swizzled)", PSP_GetVidMemBase() + Memory::VRAM_SIZE * 1, Memory::VRAM_SIZE },
|
||||
{ "vram", "mirror", "VRAM (Mirror)", PSP_GetVidMemBase() + Memory::VRAM_SIZE * 2, Memory::VRAM_SIZE },
|
||||
{ "vram", "mirror", "VRAM (Swizzled + Interleaved)", PSP_GetVidMemBase() + Memory::VRAM_SIZE * 3, Memory::VRAM_SIZE },
|
||||
{ "ram", "primary", "Kernel Memory", 0x80000000 | PSP_GetKernelMemoryBase(), kernelMemorySize },
|
||||
{ "ram", "primary", "Volatile Memory", PSP_GetVolatileMemoryStart(), volatileMemorySize },
|
||||
// Size is specially calculated.
|
||||
{ "ram", "primary", "User Memory", PSP_GetUserMemoryBase(), 0 },
|
||||
};
|
||||
|
||||
JsonWriter &json = req.Respond();
|
||||
json.pushArray("ranges");
|
||||
for (auto range : ranges) {
|
||||
uint32_t size = range.size;
|
||||
if (size == 0) {
|
||||
size = Memory::g_MemorySize;
|
||||
if (size == 0) {
|
||||
size = Memory::RAM_NORMAL_SIZE;
|
||||
}
|
||||
size -= kernelMemorySize + volatileMemorySize;
|
||||
}
|
||||
json.pushDict();
|
||||
json.writeString("type", range.type);
|
||||
json.writeString("subtype", range.subtype);
|
||||
json.writeString("name", range.name);
|
||||
json.writeUint("address", range.address);
|
||||
json.writeUint("size", size);
|
||||
json.pop();
|
||||
|
||||
// Also write the uncached range.
|
||||
json.pushDict();
|
||||
json.writeString("type", range.type);
|
||||
json.writeString("subtype", "mirror");
|
||||
json.writeString("name", std::string("Uncached ") + range.name);
|
||||
json.writeUint("address", 0x40000000 | range.address);
|
||||
json.writeUint("size", size);
|
||||
json.pop();
|
||||
}
|
||||
json.pop();
|
||||
}
|
||||
|
||||
// Update memory info tracking config (memory.info.config)
|
||||
//
|
||||
// Parameters:
|
||||
|
||||
Reference in new issue
Block a user