--- hatari/src/debug/debugui.c 2019/04/09 08:54:23 1.1.1.7 +++ hatari/src/debug/debugui.c 2019/04/09 08:55:36 1.1.1.8 @@ -29,6 +29,7 @@ const char DebugUI_fileid[] = "Hatari de #include "m68000.h" #include "memorySnapShot.h" #include "options.h" +#include "reset.h" #include "screen.h" #include "statusbar.h" #include "str.h" @@ -44,8 +45,6 @@ const char DebugUI_fileid[] = "Hatari de #include "history.h" #include "symbols.h" -int bExceptionDebugging; - FILE *debugOutput; static dbgcommand_t *debugCommand; @@ -414,6 +413,29 @@ static int DebugUI_Rename(int argc, char /** + * Command: Reset emulation + */ +static char *DebugUI_MatchReset(const char *text, int state) +{ + static const char* types[] = { "cold", "hard", "soft", "warm" }; + return DebugUI_MatchHelper(types, ARRAYSIZE(types), text, state); +} +static int DebugUI_Reset(int argc, char *argv[]) +{ + if (argc != 2) + return DebugUI_PrintCmdHelp(argv[0]); + + if (strcmp(argv[1], "soft") == 0 || strcmp(argv[1], "warm") == 0) + Reset_Warm(); + else if (strcmp(argv[1], "cold") == 0 || strcmp(argv[1], "hard") == 0) + Reset_Cold(); + else + return DebugUI_PrintCmdHelp(argv[0]); + return DEBUGGER_END; +} + + +/** * Command: Read debugger commands from a file */ static int DebugUI_CommandsFromFile(int argc, char *argv[]) @@ -601,7 +623,7 @@ static int DebugUI_ParseCommand(const ch if (retval == DEBUGGER_CMDCONT) { if (psArgs[0] != sLastCmd) - strncpy(sLastCmd, psArgs[0], sizeof(sLastCmd)); + strlcpy(sLastCmd, psArgs[0], sizeof(sLastCmd)); } else sLastCmd[0] = '\0'; @@ -855,7 +877,7 @@ static const dbgcommand_t uicommand[] = { History_Parse, History_Match, "history", "hi", "show last CPU/DSP PC values & executed instructions", - "cpu|dsp|on|off| [limit]\n" + "cpu|dsp|on|off| [limit]|save \n" "\t'cpu' and 'dsp' enable instruction history tracking for just given\n" "\tprocessor, 'on' tracks them both, 'off' will disable history.\n" "\tOptional 'limit' will set how many past instructions are tracked.\n" @@ -895,14 +917,18 @@ static const dbgcommand_t uicommand[] = "old new\n" "\tRenames file with 'old' name to 'new'.", false }, + { DebugUI_Reset, DebugUI_MatchReset, + "reset", "", + "reset emulation", + "\n", + false }, { DebugUI_SetOptions, Opt_MatchOption, "setopt", "o", "set Hatari command line and debugger options", "[bin|dec|hex|]\n" - "\tSet Hatari options. For example to enable exception catching,\n" - "\tuse following command line option: 'setopt --debug'. Special\n" - "\t'bin', 'dec' and 'hex' arguments change the default number base\n" - "\tused in debugger.", + "\tSpecial 'bin', 'dec' and 'hex' arguments change the default\n" + "\tnumber base used in debugger. lists available command\n" + "\tline options, 'setopt --help' their descriptions.", false }, { DebugUI_DoMemorySnap, NULL, "stateload", "", @@ -995,6 +1021,15 @@ void DebugUI(debug_reason_t reason) static const char *welcome = "\n----------------------------------------------------------------------" "\nYou have entered debug mode. Type c to continue emulation, h for help.\n"; + static bool recursing; + + if (recursing) + { + fprintf(stderr, "WARNING: recursive call to DebugUI (through profiler debug option?)!\n"); + recursing = false; + return; + } + recursing = true; History_Mark(reason); @@ -1056,6 +1091,8 @@ void DebugUI(debug_reason_t reason) DebugCpu_SetDebugging(); DebugDsp_SetDebugging(); + + recursing = false; }