Added "bp trig" command to see flags/address data for last hit breakpoint

This commit is contained in:
Daniel Selifonov 2018-10-26 21:41:12 -07:00
parent c510ac4fc5
commit 3c28ab2d54
No known key found for this signature in database
GPG key ID: BC7F39B2DFC02D75
3 changed files with 20 additions and 0 deletions

View file

@ -111,6 +111,8 @@ ptr_DebugGetCPUDataPtr DebugGetCPUDataPtr = NULL;
ptr_DebugBreakpointLookup DebugBreakpointLookup = NULL;
ptr_DebugBreakpointCommand DebugBreakpointCommand = NULL;
ptr_DebugBreakpointTriggeredBy DebugBreakpointTriggeredBy = NULL;
/* global variables */
m64p_dynlib_handle CoreHandle = NULL;
@ -299,6 +301,8 @@ m64p_error AttachCoreLib(const char *CoreLibFilepath)
DebugBreakpointLookup = (ptr_DebugBreakpointLookup) osal_dynlib_getproc(CoreHandle, "DebugBreakpointLookup");
DebugBreakpointCommand = (ptr_DebugBreakpointCommand) osal_dynlib_getproc(CoreHandle, "DebugBreakpointCommand");
DebugBreakpointTriggeredBy = (ptr_DebugBreakpointTriggeredBy) osal_dynlib_getproc(CoreHandle, "DebugBreakpointTriggeredBy");
return M64ERR_SUCCESS;
}
@ -366,6 +370,8 @@ m64p_error DetachCoreLib(void)
DebugBreakpointLookup = NULL;
DebugBreakpointCommand = NULL;
DebugBreakpointTriggeredBy = NULL;
/* detach the shared library */
osal_dynlib_close(CoreHandle);
CoreHandle = NULL;

View file

@ -104,5 +104,7 @@ extern ptr_DebugGetCPUDataPtr DebugGetCPUDataPtr;
extern ptr_DebugBreakpointLookup DebugBreakpointLookup;
extern ptr_DebugBreakpointCommand DebugBreakpointCommand;
extern ptr_DebugBreakpointTriggeredBy DebugBreakpointTriggeredBy;
#endif /* #define CORE_INTERFACE_H */

View file

@ -457,6 +457,18 @@ int debugger_loop(void *arg) {
printf("Added breakpoint at 0x%08X.\n", addr);
}
}
else if (strncmp(input, "bp trig", 7) == 0) {
uint32_t flags, addr;
(*DebugBreakpointTriggeredBy)(&flags, &addr);
if (flags != 0) {
printf("Breakpoint @ PC 0x%08x triggered on 0x%08x [%c%c%c]\n",
cur_pc, addr,
flags & M64P_BKP_FLAG_READ ? 'R' : ' ',
flags & M64P_BKP_FLAG_WRITE ? 'W' : ' ',
flags & M64P_BKP_FLAG_EXEC ? 'X' : ' ');
}
}
else if (strncmp(input, "bp rm ", 6) == 0) {
int index = -1;
unsigned int addr = 0;