mirror of
https://github.com/mupen64plus/mupen64plus-ui-console.git
synced 2025-04-02 10:52:34 -04:00
debugger: Add dumpmem command
This commit is contained in:
parent
198eeaa08c
commit
16f138052c
2 changed files with 44 additions and 0 deletions
3
README
3
README
|
@ -174,6 +174,9 @@ write
|
|||
write <addr> w <value> Write a word value (4 bytes) to <addr>
|
||||
write <addr> d <value> Write a double-word value (8 bytes) to <addr>
|
||||
|
||||
dumpmem <addr> <n> <filename>
|
||||
Dump <n> bytes of RDRAM memory starting at <addr> to <filename>.
|
||||
|
||||
translate
|
||||
Translates virtual memory addresses to physical memory addresses. Memory
|
||||
read/write breakpoints must operate on physical addresses, in contrast to the
|
||||
|
|
|
@ -346,6 +346,47 @@ int debugger_loop(void *arg) {
|
|||
printf("\n");
|
||||
}
|
||||
}
|
||||
else if (strncmp(input, "dumpmem", 7) == 0) {
|
||||
uint32_t addr;
|
||||
uint32_t len;
|
||||
char filename[64];
|
||||
|
||||
uint8_t *membase;
|
||||
FILE *f;
|
||||
|
||||
if (sscanf(input, "dumpmem %x 0x%x %63s", &addr, &len, filename) != 3 &&
|
||||
sscanf(input, "dumpmem %x %u %63s", &addr, &len, filename) != 3) {
|
||||
printf("Improperly formatted dumpmem command: '%s'\n", input);
|
||||
continue;
|
||||
}
|
||||
|
||||
filename[sizeof(filename) - 1] = '\0';
|
||||
|
||||
addr = (*DebugVirtualToPhysical)(addr);
|
||||
if (addr >= 0x800000) {
|
||||
printf("Requested address must be within RDRAM region\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
// 8 MB is the upper limit
|
||||
if (len > 0x800000 - addr)
|
||||
len = 0x800000 - addr;
|
||||
|
||||
membase = (*DebugMemGetPointer)(M64P_DBG_PTR_RDRAM);
|
||||
|
||||
f = fopen(filename, "wb");
|
||||
if (f == NULL) {
|
||||
printf("Could not open file '%s' for write\n", filename);
|
||||
continue;
|
||||
}
|
||||
|
||||
fwrite(membase + addr, len, 1, f);
|
||||
|
||||
fclose(f);
|
||||
|
||||
printf("Dumped 0x%08x bytes starting at 0x%08x to %s\n",
|
||||
len, addr, filename);
|
||||
}
|
||||
else if (strncmp(input, "translate", 9) == 0) {
|
||||
uint32_t virt_addr, phys_addr;
|
||||
if (sscanf(input, "translate %i", &virt_addr) == 1) {
|
||||
|
|
Loading…
Add table
Reference in a new issue