add load and save all states commands to debugger

This commit is contained in:
Thomas Jentzsch 2019-07-26 15:46:24 +02:00
parent d6e2c11275
commit 0112b89666
4 changed files with 60 additions and 6 deletions

View File

@ -262,6 +262,14 @@ void Debugger::saveState(int state)
myOSystem.state().saveState(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) void Debugger::loadState(int state)
{ {
@ -274,6 +282,18 @@ void Debugger::loadState(int state)
lockSystem(); 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() int Debugger::step()
{ {

View File

@ -52,7 +52,6 @@ class RewindManager;
using FunctionMap = std::map<string, unique_ptr<Expression>>; using FunctionMap = std::map<string, unique_ptr<Expression>>;
using FunctionDefMap = std::map<string, string>; using FunctionDefMap = std::map<string, string>;
/** /**
The base dialog for all debugging widgets in Stella. Also acts as the parent The base dialog for all debugging widgets in Stella. Also acts as the parent
for all debugging operations in Stella (parser, 6502 debugger, etc). for all debugging operations in Stella (parser, 6502 debugger, etc).
@ -299,7 +298,9 @@ class Debugger : public DialogContainer
void clearAllBreakPoints(); void clearAllBreakPoints();
void saveState(int state); void saveState(int state);
void saveAllStates();
void loadState(int state); void loadState(int state);
void loadAllStates();
private: private:
Console& myConsole; Console& myConsole;

View File

@ -53,7 +53,6 @@ using std::right;
#include "DebuggerParser.hxx" #include "DebuggerParser.hxx"
// TODO - use C++ streams instead of nasty C-strings and pointers // TODO - use C++ streams instead of nasty C-strings and pointers
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -324,7 +323,6 @@ string DebuggerParser::showWatches()
return buf.str(); return buf.str();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Private methods below // Private methods below
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1482,7 +1480,6 @@ void DebuggerParser::executeListsavestateifs()
commandResult << "no savestateifs defined"; commandResult << "no savestateifs defined";
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "listtraps" // "listtraps"
void DebuggerParser::executeListtraps() void DebuggerParser::executeListtraps()
@ -1513,6 +1510,13 @@ void DebuggerParser::executeListtraps()
commandResult << "no traps set"; commandResult << "no traps set";
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "loadallstates"
void DebuggerParser::executeLoadallstates()
{
debugger.loadAllStates();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "loadconfig" // "loadconfig"
void DebuggerParser::executeLoadconfig() void DebuggerParser::executeLoadconfig()
@ -1804,6 +1808,13 @@ void DebuggerParser::executeSavesnap()
debugger.tiaOutput().saveSnapshot(execDepth, execPrefix); debugger.tiaOutput().saveSnapshot(execDepth, execPrefix);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "saveallstates"
void DebuggerParser::executeSaveallstates()
{
debugger.saveAllStates();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "savestate" // "savestate"
void DebuggerParser::executeSavestate() void DebuggerParser::executeSavestate()
@ -2702,13 +2713,23 @@ DebuggerParser::Command DebuggerParser::commands[NumCommands] = {
{ {
"loadconfig", "loadconfig",
"Load Distella config file", "Load Distella config file",
"Example: loadconfig file.cfg", "Example: loadconfig",
false, false,
true, true,
{ Parameters::ARG_END_ARGS }, { Parameters::ARG_END_ARGS },
std::mem_fn(&DebuggerParser::executeLoadconfig) 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", "loadstate",
"Load emulator state xx (0-9)", "Load emulator state xx (0-9)",
@ -2936,6 +2957,16 @@ DebuggerParser::Command DebuggerParser::commands[NumCommands] = {
std::mem_fn(&DebuggerParser::executeSavesnap) 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", "savestate",
"Save emulator state xx (valid args 0-9)", "Save emulator state xx (valid args 0-9)",

View File

@ -88,7 +88,7 @@ class DebuggerParser
}; };
// List of commands available // List of commands available
static constexpr uInt32 NumCommands = 92; static constexpr uInt32 NumCommands = 94;
struct Command { struct Command {
string cmdString; string cmdString;
string description; string description;
@ -186,6 +186,7 @@ class DebuggerParser
void executeListfunctions(); void executeListfunctions();
void executeListsavestateifs(); void executeListsavestateifs();
void executeListtraps(); void executeListtraps();
void executeLoadallstates();
void executeLoadconfig(); void executeLoadconfig();
void executeLoadstate(); void executeLoadstate();
void executeN(); void executeN();
@ -204,6 +205,7 @@ class DebuggerParser
void executeRunToPc(); void executeRunToPc();
void executeS(); void executeS();
void executeSave(); void executeSave();
void executeSaveallstates();
void executeSaveconfig(); void executeSaveconfig();
void executeSavedisassembly(); void executeSavedisassembly();
void executeSaverom(); void executeSaverom();