From 7100bfa5b5afa2e817e20b22892b3a03e5d632ce Mon Sep 17 00:00:00 2001 From: tomcw Date: Sat, 19 Nov 2022 20:39:41 +0000 Subject: [PATCH] Debugger: LBR: support the unset/undefined case (eg. reset to undefined when beginning a new debug session) --- source/Debugger/Debug.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/source/Debugger/Debug.cpp b/source/Debugger/Debug.cpp index 5bf9d4c0..c78ed044 100644 --- a/source/Debugger/Debug.cpp +++ b/source/Debugger/Debug.cpp @@ -353,7 +353,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA static bool g_bIgnoreNextKey = false; - static WORD g_LBR = 0x0000; // Last Branch Record + const UINT LBR_UNDEFINED = -1; + static UINT g_LBR = LBR_UNDEFINED; // Last Branch Record static bool g_bScriptReadOk = false; @@ -2410,7 +2411,10 @@ Update_t CmdOut (int nArgs) //=========================================================================== Update_t CmdLBR(int nArgs) { - ConsolePrintFormat(" LBR = $%04X", g_LBR); + if (g_LBR == LBR_UNDEFINED) + ConsolePrintFormat(" LBR not set yet. Hint: Run from the debugger via 'g' command."); + else + ConsolePrintFormat(" LBR = $%04X", g_LBR); return ConsoleUpdate(); } @@ -8281,6 +8285,8 @@ void DebugBegin () DebugVideoMode::Instance().Reset(); UpdateDisplay( UPDATE_ALL ); + g_LBR = LBR_UNDEFINED; // reset LBR, so LBR isn't stale from a previous debugging session + #if DEBUG_APPLE_FONT int iFG = 7; int iBG = 4; @@ -8502,7 +8508,8 @@ void DebugContinueStepping(const bool bCallerWillUpdateDisplay/*=false*/) else if (g_bDebugBreakpointHit & BP_HIT_PC_READ_FLOATING_BUS_OR_IO_MEM) stopReason = "PC reads from floating bus or I/O memory"; else if (g_bDebugBreakpointHit & BP_HIT_INTERRUPT) - stopReason = StrFormat("Interrupt occurred at $%04X", g_LBR); + stopReason = (g_LBR == LBR_UNDEFINED) ? StrFormat("Interrupt occurred (LBR unknown)") + : StrFormat("Interrupt occurred at $%04X", g_LBR); else if (g_bDebugBreakpointHit & BP_HIT_VIDEO_POS) stopReason = StrFormat("Video scanner position matches at vpos=$%04X", g_nVideoClockVert); else if (g_bDebugBreakpointHit & BP_DMA_TO_IO_MEM) @@ -8794,7 +8801,7 @@ void DebugInitialize () void DebugReset(void) { g_videoScannerDisplayInfo.Reset(); - g_LBR = 0x0000; + g_LBR = LBR_UNDEFINED; } // Add character to the input line