--- hatari/src/debug/debugdsp.c 2019/04/09 08:49:27 1.1.1.2 +++ 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. @@ -21,6 +21,8 @@ const char DebugDsp_fileid[] = "Hatari d #include "debugdsp.h" #include "dsp.h" #include "evaluate.h" +#include "history.h" +#include "log.h" #include "memorySnapShot.h" #include "profile.h" #include "str.h" @@ -117,24 +119,9 @@ error_msg: */ static void DebugDsp_ShowAddressInfo(Uint16 addr) { - Uint32 count, cycles; - const char *symbol; - bool shown = false; - - symbol = Symbols_GetByDspAddress(addr); + const char *symbol = Symbols_GetByDspAddress(addr); if (symbol) - { - fprintf(debugOutput, "%s", symbol); - shown = true; - } - if (Profile_DspAddressData(addr, &count, &cycles)) - { - fprintf(debugOutput, "%s%d/%d times/cycles", - (shown ? ", " : ""), count, cycles); - shown = true; - } - if (shown) - fprintf(debugOutput, ":\n"); + fprintf(debugOutput, "%s:\n", symbol); } @@ -199,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; @@ -306,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(). @@ -330,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); } @@ -344,17 +355,31 @@ void DebugDsp_Check(void) { Profile_DspUpdate(); } - /* TODO: show symbols while disassembling DSP instructions */ + if (LOG_TRACE_LEVEL((TRACE_DSP_DISASM|TRACE_DSP_SYMBOLS))) + { + DebugDsp_ShowAddressInfo(DSP_GetPC()); + } if (nDspActiveCBs) { if (BreakCond_MatchDsp()) - DebugUI(); + { + 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(); + DebugUI(REASON_DSP_STEPS); + } + if (History_TrackDsp()) + { + History_AddDsp(); } } @@ -369,7 +394,8 @@ void DebugDsp_SetDebugging(void) bDspProfiling = Profile_DspStart(); nDspActiveCBs = BreakCond_BreakPointCount(true); - if (nDspActiveCBs || nDspSteps || bDspProfiling) + if (nDspActiveCBs || nDspSteps || bDspProfiling || History_TrackDsp() + || LOG_TRACE_LEVEL((TRACE_DSP_DISASM|TRACE_DSP_SYMBOLS))) DSP_SetDebugging(true); else DSP_SetDebugging(false); @@ -418,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",