Added "translate" debugger command for virtual->physical address lookup

This commit is contained in:
Daniel Selifonov 2018-10-28 16:45:03 -07:00
parent 3c28ab2d54
commit 2cdb10de7e
No known key found for this signature in database
GPG key ID: BC7F39B2DFC02D75
3 changed files with 14 additions and 0 deletions

View file

@ -112,6 +112,7 @@ ptr_DebugBreakpointLookup DebugBreakpointLookup = NULL;
ptr_DebugBreakpointCommand DebugBreakpointCommand = NULL;
ptr_DebugBreakpointTriggeredBy DebugBreakpointTriggeredBy = NULL;
ptr_DebugVirtualToPhysical DebugVirtualToPhysical = NULL;
/* global variables */
m64p_dynlib_handle CoreHandle = NULL;
@ -302,6 +303,7 @@ m64p_error AttachCoreLib(const char *CoreLibFilepath)
DebugBreakpointCommand = (ptr_DebugBreakpointCommand) osal_dynlib_getproc(CoreHandle, "DebugBreakpointCommand");
DebugBreakpointTriggeredBy = (ptr_DebugBreakpointTriggeredBy) osal_dynlib_getproc(CoreHandle, "DebugBreakpointTriggeredBy");
DebugVirtualToPhysical = (ptr_DebugVirtualToPhysical) osal_dynlib_getproc(CoreHandle, "DebugVirtualToPhysical");
return M64ERR_SUCCESS;
}
@ -371,6 +373,7 @@ m64p_error DetachCoreLib(void)
DebugBreakpointCommand = NULL;
DebugBreakpointTriggeredBy = NULL;
DebugVirtualToPhysical = NULL;
/* detach the shared library */
osal_dynlib_close(CoreHandle);

View file

@ -105,6 +105,7 @@ extern ptr_DebugBreakpointLookup DebugBreakpointLookup;
extern ptr_DebugBreakpointCommand DebugBreakpointCommand;
extern ptr_DebugBreakpointTriggeredBy DebugBreakpointTriggeredBy;
extern ptr_DebugVirtualToPhysical DebugVirtualToPhysical;
#endif /* #define CORE_INTERFACE_H */

View file

@ -347,6 +347,16 @@ int debugger_loop(void *arg) {
printf("\n");
}
}
else if (strncmp(input, "translate", 9) == 0) {
uint32_t virt_addr, phys_addr;
if (sscanf(input, "translate %i", &virt_addr) == 1) {
} else {
printf("Improperly formatted translate command: '%s'\n", input);
continue;
}
phys_addr = (*DebugVirtualToPhysical)(virt_addr);
printf("virtual 0x%08x -> physical 0x%08x\n", virt_addr, phys_addr);
}
else if (strncmp(input, "write", 5) == 0) {
uint32_t writeAddr, size=1;
uint64_t writeVal;