From 3c28ab2d54c561d3afaad6da0af805e1de91c0cf Mon Sep 17 00:00:00 2001 From: Daniel Selifonov Date: Fri, 26 Oct 2018 21:41:12 -0700 Subject: [PATCH] Added "bp trig" command to see flags/address data for last hit breakpoint --- src/core_interface.c | 6 ++++++ src/core_interface.h | 2 ++ src/debugger.c | 12 ++++++++++++ 3 files changed, 20 insertions(+) diff --git a/src/core_interface.c b/src/core_interface.c index 4765e1a..a353741 100644 --- a/src/core_interface.c +++ b/src/core_interface.c @@ -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; diff --git a/src/core_interface.h b/src/core_interface.h index d9d46dd..cbd9119 100644 --- a/src/core_interface.h +++ b/src/core_interface.h @@ -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 */ diff --git a/src/debugger.c b/src/debugger.c index 59f78a2..e40dd01 100644 --- a/src/debugger.c +++ b/src/debugger.c @@ -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;