--- hatari/src/debug/debugcpu.c 2019/04/09 08:55:33 1.1.1.7 +++ hatari/src/debug/debugcpu.c 2019/04/09 08:56:46 1.1.1.8 @@ -33,6 +33,7 @@ const char DebugCpu_fileid[] = "Hatari d #include "68kDisass.h" #include "console.h" #include "options.h" +#include "vars.h" #define MEMDUMP_COLS 16 /* memdump, number of bytes per row */ @@ -143,11 +144,11 @@ static int DebugCpu_SaveBin(int nArgc, c * Check whether given address matches any CPU symbol and whether * there's profiling information available for it. If yes, show it. */ -static void DebugCpu_ShowAddressInfo(Uint32 addr) +static void DebugCpu_ShowAddressInfo(Uint32 addr, FILE *fp) { const char *symbol = Symbols_GetByCpuAddress(addr); if (symbol) - fprintf(debugOutput, "%s:\n", symbol); + fprintf(fp, "%s:\n", symbol); } /** @@ -195,7 +196,7 @@ int DebugCpu_DisAsm(int nArgc, char *psA /* output a range */ for (insts = 0; insts < max_insts && disasm_addr < disasm_upper; insts++) { - DebugCpu_ShowAddressInfo(disasm_addr); + DebugCpu_ShowAddressInfo(disasm_addr, debugOutput); Disasm(debugOutput, (uaecptr)disasm_addr, &nextpc, 1); disasm_addr = nextpc; } @@ -217,7 +218,7 @@ static char *DebugCpu_MatchRegister(cons "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "pc", "sr" }; - return DebugUI_MatchHelper(regs, ARRAYSIZE(regs), text, state); + return DebugUI_MatchHelper(regs, ARRAY_SIZE(regs), text, state); } @@ -500,7 +501,7 @@ static char *DebugCpu_MatchNext(const ch static const char* ntypes[] = { "branch", "exception", "exreturn", "return", "subcall", "subreturn" }; - return DebugUI_MatchHelper(ntypes, ARRAYSIZE(ntypes), text, state); + return DebugUI_MatchHelper(ntypes, ARRAY_SIZE(ntypes), text, state); } /** @@ -537,15 +538,25 @@ static int DebugCpu_Next(int nArgc, char Uint32 optype, nextpc; optype = DebugCpu_OpcodeType(); - /* can this instruction be stepped normally? */ - if (optype != CALL_SUBROUTINE && optype != CALL_EXCEPTION) + /* should this instruction be stepped normally, or is it + * - subroutine call + * - exception + * - loop branch backwards + */ + if (optype == CALL_SUBROUTINE || + optype == CALL_EXCEPTION || + (optype == CALL_BRANCH && + (STMemory_ReadWord(M68000_GetPC()) & 0xf0f8) == 0x50c8 && + (Sint16)STMemory_ReadWord(M68000_GetPC()+SIZE_WORD) < 0)) + { + nextpc = Disasm_GetNextPC(M68000_GetPC()); + sprintf(command, "pc=$%x :once :quiet\n", nextpc); + } + else { nCpuSteps = 1; return DEBUGGER_END; } - - nextpc = Disasm_GetNextPC(M68000_GetPC()); - sprintf(command, "pc=$%x :once :quiet\n", nextpc); } /* use breakpoint, not steps */ if (BreakCond_Command(command, false)) @@ -617,7 +628,7 @@ void DebugCpu_Check(void) } if (LOG_TRACE_LEVEL((TRACE_CPU_DISASM|TRACE_CPU_SYMBOLS))) { - DebugCpu_ShowAddressInfo(M68000_GetPC()); + DebugCpu_ShowAddressInfo(M68000_GetPC(), TraceFile); } if (nCpuActiveCBs) { @@ -678,7 +689,7 @@ static const dbgcommand_t cpucommands[] "set CPU PC address breakpoints", BreakAddr_Description, true }, - { DebugCpu_BreakCond, BreakCond_MatchCpuVariable, + { DebugCpu_BreakCond, Vars_MatchCpuVariable, "breakpoint", "b", "set/remove/list conditional CPU breakpoints", BreakCond_Description, @@ -774,7 +785,7 @@ int DebugCpu_Init(const dbgcommand_t **t disasm_addr = 0; *table = cpucommands; - return ARRAYSIZE(cpucommands); + return ARRAY_SIZE(cpucommands); } /**