From 0112b89666cf832aa26c2b037e38e5b8b0bef898 Mon Sep 17 00:00:00 2001 From: Thomas Jentzsch Date: Fri, 26 Jul 2019 15:46:24 +0200 Subject: [PATCH] add load and save all states commands to debugger --- src/debugger/Debugger.cxx | 20 +++++++++++++++++ src/debugger/Debugger.hxx | 3 ++- src/debugger/DebuggerParser.cxx | 39 +++++++++++++++++++++++++++++---- src/debugger/DebuggerParser.hxx | 4 +++- 4 files changed, 60 insertions(+), 6 deletions(-) diff --git a/src/debugger/Debugger.cxx b/src/debugger/Debugger.cxx index 93397e167..3592ebc2e 100644 --- a/src/debugger/Debugger.cxx +++ b/src/debugger/Debugger.cxx @@ -262,6 +262,14 @@ void Debugger::saveState(int state) myOSystem.state().saveState(state); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Debugger::saveAllStates() +{ + // Saving states is implicitly a read-only operation, so we keep the + // system locked, so no changes can occur + myOSystem.state().rewindManager().saveAllStates(); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Debugger::loadState(int state) { @@ -274,6 +282,18 @@ void Debugger::loadState(int state) lockSystem(); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Debugger::loadAllStates() +{ + // We're loading new states, so we start with a clean slate + mySystem.clearDirtyPages(); + + // State loading could initiate a bankswitch, so we allow it temporarily + unlockSystem(); + myOSystem.state().rewindManager().loadAllStates(); + lockSystem(); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - int Debugger::step() { diff --git a/src/debugger/Debugger.hxx b/src/debugger/Debugger.hxx index 8a403006d..6c6a21050 100644 --- a/src/debugger/Debugger.hxx +++ b/src/debugger/Debugger.hxx @@ -52,7 +52,6 @@ class RewindManager; using FunctionMap = std::map>; using FunctionDefMap = std::map; - /** The base dialog for all debugging widgets in Stella. Also acts as the parent for all debugging operations in Stella (parser, 6502 debugger, etc). @@ -299,7 +298,9 @@ class Debugger : public DialogContainer void clearAllBreakPoints(); void saveState(int state); + void saveAllStates(); void loadState(int state); + void loadAllStates(); private: Console& myConsole; diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index 77a0420e1..05a0e29e3 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -53,7 +53,6 @@ using std::right; #include "DebuggerParser.hxx" - // TODO - use C++ streams instead of nasty C-strings and pointers // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -324,7 +323,6 @@ string DebuggerParser::showWatches() return buf.str(); } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Private methods below // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1482,7 +1480,6 @@ void DebuggerParser::executeListsavestateifs() commandResult << "no savestateifs defined"; } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // "listtraps" void DebuggerParser::executeListtraps() @@ -1513,6 +1510,13 @@ void DebuggerParser::executeListtraps() commandResult << "no traps set"; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// "loadallstates" +void DebuggerParser::executeLoadallstates() +{ + debugger.loadAllStates(); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // "loadconfig" void DebuggerParser::executeLoadconfig() @@ -1804,6 +1808,13 @@ void DebuggerParser::executeSavesnap() debugger.tiaOutput().saveSnapshot(execDepth, execPrefix); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// "saveallstates" +void DebuggerParser::executeSaveallstates() +{ + debugger.saveAllStates(); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // "savestate" void DebuggerParser::executeSavestate() @@ -2702,13 +2713,23 @@ DebuggerParser::Command DebuggerParser::commands[NumCommands] = { { "loadconfig", "Load Distella config file", - "Example: loadconfig file.cfg", + "Example: loadconfig", false, true, { Parameters::ARG_END_ARGS }, std::mem_fn(&DebuggerParser::executeLoadconfig) }, + { + "loadallstates", + "Load all emulator states", + "Example: loadallstates (no parameters)", + false, + true, + { Parameters::ARG_END_ARGS }, + std::mem_fn(&DebuggerParser::executeLoadallstates) + }, + { "loadstate", "Load emulator state xx (0-9)", @@ -2936,6 +2957,16 @@ DebuggerParser::Command DebuggerParser::commands[NumCommands] = { std::mem_fn(&DebuggerParser::executeSavesnap) }, + { + "saveallstates", + "Save all emulator states", + "Example: saveallstates (no parameters)", + false, + false, + { Parameters::ARG_END_ARGS }, + std::mem_fn(&DebuggerParser::executeSaveallstates) + }, + { "savestate", "Save emulator state xx (valid args 0-9)", diff --git a/src/debugger/DebuggerParser.hxx b/src/debugger/DebuggerParser.hxx index 063173540..ecfc84148 100644 --- a/src/debugger/DebuggerParser.hxx +++ b/src/debugger/DebuggerParser.hxx @@ -88,7 +88,7 @@ class DebuggerParser }; // List of commands available - static constexpr uInt32 NumCommands = 92; + static constexpr uInt32 NumCommands = 94; struct Command { string cmdString; string description; @@ -186,6 +186,7 @@ class DebuggerParser void executeListfunctions(); void executeListsavestateifs(); void executeListtraps(); + void executeLoadallstates(); void executeLoadconfig(); void executeLoadstate(); void executeN(); @@ -204,6 +205,7 @@ class DebuggerParser void executeRunToPc(); void executeS(); void executeSave(); + void executeSaveallstates(); void executeSaveconfig(); void executeSavedisassembly(); void executeSaverom();