Debugger stop reason (#1200)

* Add global breakpoint so we can display last breakpoint triggered information

* Cleanup

* 2.9.1.15 Pretty print what register and breakpoint number when a breakpoint is triggered

* Bump debugger version 2.9.1.15

* Fix missing space between type and var

* Cleanup

* Add CHC_REGS
This commit is contained in:
Michael "Code Poet" Pohoreski 2023-03-26 10:54:30 -07:00 committed by GitHub
parent 4c08b9c20c
commit 72566373ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 8 deletions

View File

@ -1,6 +1,8 @@
/* /*
2.9.1.16 Added: QoL to BPL. Header and colorized address, mem, and symbols. 2.9.1.16 Added: QoL to BPL. Header and colorized address, mem, and symbols.
2.9.1.15 Added: QoL when a breakpoint register is hit display which register and breakpoint triggered it.
Example:
Stop reason: Register PC matches breakpoint #0
2.9.1.14 Fix disassembly when in middle of data 2.9.1.14 Fix disassembly when in middle of data
Example: Example:
ASC 7D0:7D7 ASC 7D0:7D7

View File

@ -53,7 +53,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#define MAKE_VERSION(a,b,c,d) ((a<<24) | (b<<16) | (c<<8) | (d)) #define MAKE_VERSION(a,b,c,d) ((a<<24) | (b<<16) | (c<<8) | (d))
// See /docs/Debugger_Changelog.txt for full details // See /docs/Debugger_Changelog.txt for full details
const int DEBUGGER_VERSION = MAKE_VERSION(2,9,1,14); const int DEBUGGER_VERSION = MAKE_VERSION(2,9,1,15);
// Public _________________________________________________________________________________________ // Public _________________________________________________________________________________________
@ -85,9 +85,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
static DebugBreakOnDMA g_DebugBreakOnDMA[NUM_BREAK_ON_DMA]; static DebugBreakOnDMA g_DebugBreakOnDMA[NUM_BREAK_ON_DMA];
static DebugBreakOnDMA g_DebugBreakOnDMAIO; static DebugBreakOnDMA g_DebugBreakOnDMAIO;
int g_bDebugBreakpointHit = 0; // See: BreakpointHit_t int g_bDebugBreakpointHit = 0; // See: BreakpointHit_t
static Breakpoint_t *g_pDebugBreakpointHit = nullptr; // NOTE: Only valid for BP_HIT_REG, see: CheckBreakpointsReg()
int g_nBreakpoints = 0; int g_nBreakpoints = 0;
Breakpoint_t g_aBreakpoints[ MAX_BREAKPOINTS ]; Breakpoint_t g_aBreakpoints[ MAX_BREAKPOINTS ];
// NOTE: BreakpointSource_t and g_aBreakpointSource must match! // NOTE: BreakpointSource_t and g_aBreakpointSource must match!
@ -1321,6 +1322,8 @@ int CheckBreakpointsIO ()
//=========================================================================== //===========================================================================
int CheckBreakpointsReg () int CheckBreakpointsReg ()
{ {
g_pDebugBreakpointHit = nullptr;
int iAnyBreakpointHit = 0; int iAnyBreakpointHit = 0;
for (int iBreakpoint = 0; iBreakpoint < MAX_BREAKPOINTS; iBreakpoint++) for (int iBreakpoint = 0; iBreakpoint < MAX_BREAKPOINTS; iBreakpoint++)
@ -1334,7 +1337,7 @@ int CheckBreakpointsReg ()
switch (pBP->eSource) switch (pBP->eSource)
{ {
case BP_SRC_REG_PC: case BP_SRC_REG_PC:
bBreakpointHit = _CheckBreakpointValue( pBP, regs.pc ); bBreakpointHit = _CheckBreakpointValue( pBP, regs.pc );
break; break;
case BP_SRC_REG_A: case BP_SRC_REG_A:
@ -1359,6 +1362,7 @@ int CheckBreakpointsReg ()
if (bBreakpointHit) if (bBreakpointHit)
{ {
iAnyBreakpointHit = hitBreakpoint(pBP, BP_HIT_REG); iAnyBreakpointHit = hitBreakpoint(pBP, BP_HIT_REG);
g_pDebugBreakpointHit = pBP; // Save breakpoint so we can display which register triggered the breakpoint.
} }
} }
@ -8609,7 +8613,22 @@ void DebugContinueStepping (const bool bCallerWillUpdateDisplay/*=false*/)
else if (g_bDebugBreakpointHit & BP_HIT_OPCODE) else if (g_bDebugBreakpointHit & BP_HIT_OPCODE)
stopReason = "Opcode match"; stopReason = "Opcode match";
else if (g_bDebugBreakpointHit & BP_HIT_REG) else if (g_bDebugBreakpointHit & BP_HIT_REG)
stopReason = "Register matches value"; {
if (g_pDebugBreakpointHit)
{
int iBreakpoint = (g_pDebugBreakpointHit - g_aBreakpoints);
stopReason = StrFormat( "Register %s%s%s matches breakpoint %s#%s%d",
CHC_REGS,
g_aBreakpointSource[ g_pDebugBreakpointHit->eSource ],
CHC_DEFAULT,
CHC_ARG_SEP,
CHC_NUM_HEX,
iBreakpoint
);
}
else
stopReason = "Register matches value";
}
else if (g_bDebugBreakpointHit & BP_HIT_MEM) else if (g_bDebugBreakpointHit & BP_HIT_MEM)
stopReason = StrFormat("Memory access at $%04X", g_uBreakMemoryAddress); stopReason = StrFormat("Memory access at $%04X", g_uBreakMemoryAddress);
else if (g_bDebugBreakpointHit & BP_HIT_MEMW) else if (g_bDebugBreakpointHit & BP_HIT_MEMW)
@ -8631,7 +8650,7 @@ void DebugContinueStepping (const bool bCallerWillUpdateDisplay/*=false*/)
skipStopReason = true; skipStopReason = true;
if (!skipStopReason) if (!skipStopReason)
ConsoleBufferPushFormat( "Stop reason: %s", stopReason.c_str() ); ConsolePrintFormat( CHC_INFO "Stop reason: " CHC_DEFAULT "%s", stopReason.c_str() );
for (int i = 0; i < NUM_BREAK_ON_DMA; i++) for (int i = 0; i < NUM_BREAK_ON_DMA; i++)
{ {
@ -8642,7 +8661,7 @@ void DebugContinueStepping (const bool bCallerWillUpdateDisplay/*=false*/)
stopReason = StrFormat("HDD DMA to memory $%04X-%04X (BP#%d)", g_DebugBreakOnDMA[i].memoryAddr, g_DebugBreakOnDMA[i].memoryAddrEnd, g_DebugBreakOnDMA[i].BPid); stopReason = StrFormat("HDD DMA to memory $%04X-%04X (BP#%d)", g_DebugBreakOnDMA[i].memoryAddr, g_DebugBreakOnDMA[i].memoryAddrEnd, g_DebugBreakOnDMA[i].BPid);
else if (nDebugBreakpointHit & BP_DMA_FROM_MEM) else if (nDebugBreakpointHit & BP_DMA_FROM_MEM)
stopReason = StrFormat("HDD DMA from memory $%04X-%04X (BP#%d)", g_DebugBreakOnDMA[i].memoryAddr, g_DebugBreakOnDMA[i].memoryAddrEnd, g_DebugBreakOnDMA[i].BPid); stopReason = StrFormat("HDD DMA from memory $%04X-%04X (BP#%d)", g_DebugBreakOnDMA[i].memoryAddr, g_DebugBreakOnDMA[i].memoryAddrEnd, g_DebugBreakOnDMA[i].BPid);
ConsoleBufferPushFormat("Stop reason: %s", stopReason.c_str()); ConsolePrintFormat( CHC_INFO "Stop reason: " CHC_DEFAULT "%s", stopReason.c_str() );
} }
} }

View File

@ -80,6 +80,7 @@
#define CHC_STRING "`6" // #define CHC_STRING "`6" //
#define CHC_EXAMPLE "`:" #define CHC_EXAMPLE "`:"
#define CHC_PATH "`:" // Light Blue #define CHC_PATH "`:" // Light Blue
#define CHC_REGS "`6" // Cyan
#else #else
#define CHC_DEFAULT "" #define CHC_DEFAULT ""
#define CHC_USAGE "" #define CHC_USAGE ""