Debugger: Add a simple LBR command
This commit is contained in:
parent
4c73a8003a
commit
8575238d69
3 changed files with 38 additions and 1 deletions
|
@ -315,6 +315,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
static bool g_bIgnoreNextKey = false;
|
static bool g_bIgnoreNextKey = false;
|
||||||
|
|
||||||
|
static WORD g_LBR = 0x0000; // Last Branch Record
|
||||||
|
|
||||||
// Private ________________________________________________________________________________________
|
// Private ________________________________________________________________________________________
|
||||||
|
|
||||||
|
|
||||||
|
@ -2184,6 +2186,13 @@ Update_t CmdOut (int nArgs)
|
||||||
return UPDATE_CONSOLE_DISPLAY; // TODO: Verify // 1
|
return UPDATE_CONSOLE_DISPLAY; // TODO: Verify // 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
Update_t CmdLBR(int nArgs)
|
||||||
|
{
|
||||||
|
TCHAR sText[CONSOLE_WIDTH];
|
||||||
|
ConsolePrintFormat(sText, " LBR = $%04X", g_LBR);
|
||||||
|
return ConsoleUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
// Color __________________________________________________________________________________________
|
// Color __________________________________________________________________________________________
|
||||||
|
|
||||||
|
@ -8145,6 +8154,28 @@ static void CheckBreakOpcode( int iOpcode )
|
||||||
g_bDebugBreakpointHit |= BP_HIT_OPCODE;
|
g_bDebugBreakpointHit |= BP_HIT_OPCODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void UpdateLBR(void)
|
||||||
|
{
|
||||||
|
const BYTE nOpcode = *(mem + regs.pc);
|
||||||
|
|
||||||
|
bool isControlFlowOpcode =
|
||||||
|
nOpcode == OPCODE_BRK ||
|
||||||
|
nOpcode == OPCODE_JSR ||
|
||||||
|
nOpcode == OPCODE_JMP_A ||
|
||||||
|
nOpcode == OPCODE_RTI ||
|
||||||
|
nOpcode == OPCODE_RTS ||
|
||||||
|
nOpcode == OPCODE_JMP_NA;
|
||||||
|
|
||||||
|
if (GetMainCpu() == CPU_65C02 && nOpcode == OPCODE_JMP_IAX)
|
||||||
|
isControlFlowOpcode = true;
|
||||||
|
|
||||||
|
if (g_aOpcodes[nOpcode].nAddressMode == AM_R)
|
||||||
|
isControlFlowOpcode = true;
|
||||||
|
|
||||||
|
if (isControlFlowOpcode)
|
||||||
|
g_LBR = regs.pc;
|
||||||
|
}
|
||||||
|
|
||||||
void DebugContinueStepping(const bool bCallerWillUpdateDisplay/*=false*/)
|
void DebugContinueStepping(const bool bCallerWillUpdateDisplay/*=false*/)
|
||||||
{
|
{
|
||||||
static bool bForceSingleStepNext = false; // Allow at least one instruction to execute so we don't trigger on the same invalid opcode
|
static bool bForceSingleStepNext = false; // Allow at least one instruction to execute so we don't trigger on the same invalid opcode
|
||||||
|
@ -8186,7 +8217,7 @@ void DebugContinueStepping(const bool bCallerWillUpdateDisplay/*=false*/)
|
||||||
BYTE nOpcode = *(mem+regs.pc);
|
BYTE nOpcode = *(mem+regs.pc);
|
||||||
|
|
||||||
// Update profiling stats
|
// Update profiling stats
|
||||||
int nOpmode = g_aOpcodes[ nOpcode ].nAddressMode;
|
int nOpmode = g_aOpcodes[ nOpcode ].nAddressMode;
|
||||||
g_aProfileOpcodes[ nOpcode ].m_nCount++;
|
g_aProfileOpcodes[ nOpcode ].m_nCount++;
|
||||||
g_aProfileOpmodes[ nOpmode ].m_nCount++;
|
g_aProfileOpmodes[ nOpmode ].m_nCount++;
|
||||||
|
|
||||||
|
@ -8206,6 +8237,8 @@ void DebugContinueStepping(const bool bCallerWillUpdateDisplay/*=false*/)
|
||||||
|
|
||||||
if (bDoSingleStep)
|
if (bDoSingleStep)
|
||||||
{
|
{
|
||||||
|
UpdateLBR();
|
||||||
|
|
||||||
SingleStep(g_bGoCmd_ReinitFlag);
|
SingleStep(g_bGoCmd_ReinitFlag);
|
||||||
g_bGoCmd_ReinitFlag = false;
|
g_bGoCmd_ReinitFlag = false;
|
||||||
|
|
||||||
|
@ -8494,6 +8527,7 @@ void DebugInitialize ()
|
||||||
void DebugReset(void)
|
void DebugReset(void)
|
||||||
{
|
{
|
||||||
g_videoScannerDisplayInfo.Reset();
|
g_videoScannerDisplayInfo.Reset();
|
||||||
|
g_LBR = 0x0000;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add character to the input line
|
// Add character to the input line
|
||||||
|
|
|
@ -52,6 +52,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
{TEXT("JSR") , CmdJSR , CMD_JSR , "Call sub-routine" },
|
{TEXT("JSR") , CmdJSR , CMD_JSR , "Call sub-routine" },
|
||||||
{TEXT("NOP") , CmdNOP , CMD_NOP , "Zap the current instruction with a NOP" },
|
{TEXT("NOP") , CmdNOP , CMD_NOP , "Zap the current instruction with a NOP" },
|
||||||
{TEXT("OUT") , CmdOut , CMD_OUT , "Output byte to IO $C0xx" },
|
{TEXT("OUT") , CmdOut , CMD_OUT , "Output byte to IO $C0xx" },
|
||||||
|
{TEXT("LBR") , CmdLBR , CMD_LBR , "Show Last Branch Record" },
|
||||||
// CPU - Meta Info
|
// CPU - Meta Info
|
||||||
{TEXT("PROFILE") , CmdProfile , CMD_PROFILE , "List/Save 6502 profiling" },
|
{TEXT("PROFILE") , CmdProfile , CMD_PROFILE , "List/Save 6502 profiling" },
|
||||||
{TEXT("R") , CmdRegisterSet , CMD_REGISTER_SET , "Set register" },
|
{TEXT("R") , CmdRegisterSet , CMD_REGISTER_SET , "Set register" },
|
||||||
|
|
|
@ -295,6 +295,7 @@
|
||||||
, CMD_JSR
|
, CMD_JSR
|
||||||
, CMD_NOP
|
, CMD_NOP
|
||||||
, CMD_OUT
|
, CMD_OUT
|
||||||
|
, CMD_LBR
|
||||||
// CPU - Meta Info
|
// CPU - Meta Info
|
||||||
, CMD_PROFILE
|
, CMD_PROFILE
|
||||||
, CMD_REGISTER_SET
|
, CMD_REGISTER_SET
|
||||||
|
@ -605,6 +606,7 @@
|
||||||
Update_t CmdJSR (int nArgs);
|
Update_t CmdJSR (int nArgs);
|
||||||
Update_t CmdNOP (int nArgs);
|
Update_t CmdNOP (int nArgs);
|
||||||
Update_t CmdOut (int nArgs);
|
Update_t CmdOut (int nArgs);
|
||||||
|
Update_t CmdLBR (int nArgs);
|
||||||
Update_t CmdStepOver (int nArgs);
|
Update_t CmdStepOver (int nArgs);
|
||||||
Update_t CmdStepOut (int nArgs);
|
Update_t CmdStepOut (int nArgs);
|
||||||
Update_t CmdTrace (int nArgs); // alias for CmdStepIn
|
Update_t CmdTrace (int nArgs); // alias for CmdStepIn
|
||||||
|
|
Loading…
Add table
Reference in a new issue