--- hatari/src/debug/debugdsp.c 2019/04/09 08:52:00 1.1.1.4 +++ hatari/src/debug/debugdsp.c 2019/04/09 08:53:05 1.1.1.5 @@ -1,8 +1,8 @@ /* Hatari - debugdsp.c - This file is distributed under the GNU Public License, version 2 or at - your option any later version. Read the file gpl.txt for details. + This file is distributed under the GNU General Public License, version 2 + or at your option any later version. Read the file gpl.txt for details. debugdsp.c - function needed for the DSP debugging tasks like memory and register dumps. @@ -186,7 +186,7 @@ int DebugDsp_DisAsm(int nArgc, char *psA printf("DSP disasm 0x%hx-0x%hx:\n", dsp_disasm_addr, dsp_disasm_upper); while (dsp_disasm_addr < dsp_disasm_upper) { DebugDsp_ShowAddressInfo(dsp_disasm_addr); - dsp_disasm_addr = DSP_DisasmAddress(dsp_disasm_addr, dsp_disasm_addr); + dsp_disasm_addr = DSP_DisasmAddress(stderr, dsp_disasm_addr, dsp_disasm_addr); } return DEBUGGER_CMDCONT; @@ -293,6 +293,31 @@ static int DebugDsp_Continue(int nArgc, return DEBUGGER_END; } +/** + * Command: Single-step DSP + */ +static int DebugDsp_Step(int nArgc, char *psArgv[]) +{ + nDspSteps = 1; + return DEBUGGER_END; +} + +/** + * Command: Step DSP, but proceed through subroutines + * Does this by temporary conditional breakpoint + */ +static int DebugDsp_Next(int nArgc, char *psArgv[]) +{ + char command[32]; + Uint16 nextpc = DSP_GetNextPC(DSP_GetPC()); + sprintf(command, "pc=$%x :once :quiet\n", nextpc); + if (BreakCond_Command(command, true)) { + nDspSteps = 0; /* using breakpoint, not steps */ + return DEBUGGER_END; + } + return DEBUGGER_CMDDONE; +} + /** * DSP wrapper for BreakAddr_Command(). @@ -317,8 +342,7 @@ static int DebugDsp_BreakCond(int nArgc, */ static int DebugDsp_Profile(int nArgc, char *psArgs[]) { - Profile_Command(nArgc, psArgs, true); - return DEBUGGER_CMDDONE; + return Profile_Command(nArgc, psArgs, true); } @@ -338,15 +362,22 @@ void DebugDsp_Check(void) if (nDspActiveCBs) { if (BreakCond_MatchDsp()) + { DebugUI(REASON_DSP_BREAKPOINT); + /* make sure we don't decrease step count + * below, before even getting out of here + */ + if (nDspSteps) + nDspSteps++; + } } if (nDspSteps) { - nDspSteps -= 1; + nDspSteps--; if (nDspSteps == 0) DebugUI(REASON_DSP_STEPS); } - if (bHistoryEnabled) + if (History_TrackDsp()) { History_AddDsp(); } @@ -363,7 +394,7 @@ void DebugDsp_SetDebugging(void) bDspProfiling = Profile_DspStart(); nDspActiveCBs = BreakCond_BreakPointCount(true); - if (nDspActiveCBs || nDspSteps || bDspProfiling || bHistoryEnabled + if (nDspActiveCBs || nDspSteps || bDspProfiling || History_TrackDsp() || LOG_TRACE_LEVEL((TRACE_DSP_DISASM|TRACE_DSP_SYMBOLS))) DSP_SetDebugging(true); else @@ -413,6 +444,19 @@ static const dbgcommand_t dspcommands[] "[REG=value]" "\tSet or dump contents of DSP registers.", true }, + { DebugDsp_Step, NULL, + "dspstep", "ds", + "single-step DSP", + "\n" + "\tExecute next DSP instruction (equals 'dc 1')", + false }, + { DebugDsp_Next, NULL, + "dspnext", "dn", + "step DSP, proceeding through subroutine calls", + "\n" + "\tLike the 'dspstep' command as long as subroutine calls do not\n" + "\thappen. When they do, the call is treated as one instruction.", + false }, { DebugDsp_Continue, NULL, "dspcont", "dc", "continue emulation / DSP single-stepping",