--- hatari/src/debug/history.c 2019/04/09 08:50:22 1.1 +++ hatari/src/debug/history.c 2019/04/09 08:53:05 1.1.1.2 @@ -3,8 +3,8 @@ * * Copyright (C) 2011 by Eero Tamminen * - * 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. * * history.c - functions for debugger entry & breakpoint history */ @@ -22,7 +22,8 @@ const char History_fileid[] = "Hatari hi #include "m68000.h" #include "68kDisass.h" -bool bHistoryEnabled; + +history_type_t HistoryTracking; #define HISTORY_ITEMS 256 @@ -48,7 +49,7 @@ static struct { /** * Convert debugger entry/breakpoint entry reason to a string */ -const char* History_ReasonStr(debug_reason_t reason) +static const char* History_ReasonStr(debug_reason_t reason) { switch(reason) { case REASON_CPU_EXCEPTION: @@ -70,16 +71,34 @@ const char* History_ReasonStr(debug_reas /** - * Enable/disable history collecting. - * Clear history on disabling as data wouldn't - * then be anymore valid. + * Set what kind of history is collected. + * Clear history if tracking type changes as rest of + * data wouldn't then be anymore valid. */ -void History_Enable(bool enable) +static void History_Enable(history_type_t track) { - if (!enable) { + const char *msg; + if (track != HistoryTracking) { memset(&History, 0, sizeof(History)); } - bHistoryEnabled = enable; + switch (track) { + case HISTORY_TRACK_NONE: + msg = "disabled"; + break; + case HISTORY_TRACK_CPU: + msg = "enabled for CPU"; + break; + case HISTORY_TRACK_DSP: + msg = "enabled for DSP"; + break; + case HISTORY_TRACK_ALL: + msg = "enabled for CPU & DSP"; + break; + default: + msg = "error"; + } + HistoryTracking = track; + fprintf(stderr, "History tracking %s.\n", msg); } /** @@ -172,10 +191,10 @@ void History_Show(Uint32 count) if (History.item[i].for_dsp) { Uint16 pc = History.item[i].pc.dsp; - DSP_DisasmAddress(pc, pc); + DSP_DisasmAddress(stderr, pc, pc); } else { Uint32 dummy; - Disasm(stderr, History.item[i].pc.cpu, &dummy, 1, DISASM_ENGINE_EXT); + Disasm(stderr, History.item[i].pc.cpu, &dummy, 1); } if (History.item[i].reason != REASON_NONE) { fprintf(stderr, "Debugger: *%s*\n", History_ReasonStr(History.item[i].reason)); @@ -199,11 +218,19 @@ int History_Parse(int nArgc, char *psArg if (count <= 0 || count > HISTORY_ITEMS) { /* no count -> enable or disable? */ if (strcmp(psArgs[1], "on") == 0) { - History_Enable(true); + History_Enable(HISTORY_TRACK_ALL); return DEBUGGER_CMDDONE; } if (strcmp(psArgs[1], "off") == 0) { - History_Enable(false); + History_Enable(HISTORY_TRACK_NONE); + return DEBUGGER_CMDDONE; + } + if (strcmp(psArgs[1], "cpu") == 0) { + History_Enable(HISTORY_TRACK_CPU); + return DEBUGGER_CMDDONE; + } + if (strcmp(psArgs[1], "dsp") == 0) { + History_Enable(HISTORY_TRACK_DSP); return DEBUGGER_CMDDONE; } fprintf(stderr, "History range is 1-%d!\n", HISTORY_ITEMS);