enhanced save command, saves to user directory by default

added "autosave" command
This commit is contained in:
Thomas Jentzsch 2021-05-13 17:26:22 +02:00
parent 20aa94f4fc
commit 16a3a977dd
6 changed files with 80 additions and 30 deletions

View File

@ -862,13 +862,16 @@ later re-use.</p>
<ul> <ul>
<li> <li>
<b><a name="savecmd">save</a></b>: If you've defined a lot of complex functions, you probably will <b><a name="savecmd">save</a></b>: If you've defined a lot of complex
want to re-use them in future runs of the debugger. You can save all functions, you probably will want to re-use them in future runs of the
your functions, breakpoints, conditional breaks, traps and watches with the debugger. You can save all your functions, breakpoints, conditional breaks,
"save" command. If you name your saved file the same as the ROM filename traps and watches with the "save" command. By default it is saved in the
and place it in the ROM directory, it will be auto-loaded next time you user directory with the same as the ROM filename. In this case it will be
load the same ROM in Stella. The saved file is just a plain text file auto-loaded next time you load the same ROM in Stella. The saved file is
called "&lt;rom_filename&gt;.script", so you can edit it and add new functions, etc. just a plain text file called "&lt;rom_filename&gt;.script", so you can
edit it and add more functions, etc.
<p>Use "autoSave" to automatically execute the "save" command when
exiting the debugger.</p>
<p>Note: While "save" is ROM specific, you can also create a file called <p>Note: While "save" is ROM specific, you can also create a file called
"autoexec.script" which will be loaded when the debugger starts, no matter "autoexec.script" which will be loaded when the debugger starts, no matter
what ROM you have loaded.<p> what ROM you have loaded.<p>
@ -927,6 +930,7 @@ Type "help 'cmd'" to see extended information about the given command.</p>
<pre> <pre>
a - Set Accumulator to &lt;value&gt; a - Set Accumulator to &lt;value&gt;
aud - Mark 'AUD' range in disassembly aud - Mark 'AUD' range in disassembly
autoSave - Automatically execute "save" when exiting the debugger
base - Set default number base to &lt;base&gt; (bin, dec, hex) base - Set default number base to &lt;base&gt; (bin, dec, hex)
bCol - Mark 'BCOL' range in disassembly bCol - Mark 'BCOL' range in disassembly
break - Set/clear breakpoint at &lt;address&gt; and &lt;bank&gt; break - Set/clear breakpoint at &lt;address&gt; and &lt;bank&gt;
@ -997,7 +1001,7 @@ clearSaveStateIfs - Clear all saveState points
runTo - Run until string xx in disassembly runTo - Run until string xx in disassembly
runToPc - Run until PC is set to value xx runToPc - Run until PC is set to value xx
s - Set Stack Pointer to value xx s - Set Stack Pointer to value xx
save - Save breaks, watches, traps and functions to file <xx or ?> save - Save breaks, watches, traps and functions to file [xx or ?]
saveAccess - Save access counters to CSV file [?] saveAccess - Save access counters to CSV file [?]
saveConfig - Save DiStella config file (with default name) saveConfig - Save DiStella config file (with default name)
saveDis - Save DiStella disassembly to file [?] saveDis - Save DiStella disassembly to file [?]

View File

@ -153,6 +153,9 @@ bool Debugger::startWithFatalError(const string& message)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::quit(bool exitrom) void Debugger::quit(bool exitrom)
{ {
if(myOSystem.settings().getBool("dbg.autosave"))
myParser->run("save");
if(exitrom) if(exitrom)
myOSystem.eventHandler().handleEvent(Event::ExitGame); myOSystem.eventHandler().handleEvent(Event::ExitGame);
else else
@ -173,7 +176,8 @@ string Debugger::autoExec(StringList* history)
<< myParser->exec(autoexec, history) << endl; << myParser->exec(autoexec, history) << endl;
// Also, "romname.script" if present // Also, "romname.script" if present
FilesystemNode romname(myOSystem.romFile().getPathWithExt(".script")); const string path = myOSystem.userDir().getPath() + myOSystem.romFile().getNameWithExt(".script");
FilesystemNode romname(path);
buf << myParser->exec(romname, history) << endl; buf << myParser->exec(romname, history) << endl;
// Init builtins // Init builtins

View File

@ -758,6 +758,16 @@ void DebuggerParser::executeAud()
executeDirective(Device::AUD); executeDirective(Device::AUD);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "autoSave"
void DebuggerParser::executeAutoSave()
{
bool enable = !settings.getBool("dbg.autosave");
settings.setValue("dbg.autosave", enable);
commandResult << "autoSave " << (enable ? "enabled" : "disabled");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "base" // "base"
void DebuggerParser::executeBase() void DebuggerParser::executeBase()
@ -1909,13 +1919,15 @@ void DebuggerParser::executeS()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "save" // "save"
void DebuggerParser::executeSave() void DebuggerParser::executeSave()
{
if(argCount && argStrings[0] == "?")
{ {
DebuggerDialog* dlg = debugger.myDialog; DebuggerDialog* dlg = debugger.myDialog;
const string fileName = dlg->instance().userDir().getPath() + cartName() + ".script";
BrowserDialog::show(dlg, "Save Workbench as", if(argCount)
dlg->instance().userDir().getPath() + cartName() + ".script", {
if(argStrings[0] == "?")
{
BrowserDialog::show(dlg, "Save Workbench as", fileName,
BrowserDialog::Mode::FileSave, BrowserDialog::Mode::FileSave,
[this, dlg](bool OK, const FilesystemNode& node) [this, dlg](bool OK, const FilesystemNode& node)
{ {
@ -1929,6 +1941,9 @@ void DebuggerParser::executeSave()
else else
commandResult << saveScriptFile(argStrings[0]); commandResult << saveScriptFile(argStrings[0]);
} }
else
commandResult << saveScriptFile(fileName);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "saveAccess" // "saveAccess"
@ -2516,6 +2531,16 @@ DebuggerParser::CommandArray DebuggerParser::commands = { {
std::mem_fn(&DebuggerParser::executeAud) std::mem_fn(&DebuggerParser::executeAud)
}, },
{
"autoSave",
"Toggle automatic saving of commands (see 'save')",
"Example: autoSave (no parameters)",
false,
true,
{ Parameters::ARG_END_ARGS },
std::mem_fn(&DebuggerParser::executeAutoSave)
},
{ {
"base", "base",
"Set default number base to <base>", "Set default number base to <base>",
@ -3230,10 +3255,10 @@ DebuggerParser::CommandArray DebuggerParser::commands = { {
{ {
"save", "save",
"Save breaks, watches, traps and functions to file <xx or ?>", "Save breaks, watches, traps and functions to file [xx or ?]",
"Example: save commands.script, save ?\n" "Example: save, save commands.script, save ?\n"
"NOTE: saves to user dir by default", "NOTE: saves to user dir by default",
true, false,
false, false,
{ Parameters::ARG_FILE, Parameters::ARG_END_ARGS }, { Parameters::ARG_FILE, Parameters::ARG_END_ARGS },
std::mem_fn(&DebuggerParser::executeSave) std::mem_fn(&DebuggerParser::executeSave)

View File

@ -101,7 +101,7 @@ class DebuggerParser
std::array<Parameters, 10> parms; std::array<Parameters, 10> parms;
std::function<void (DebuggerParser*)> executor; std::function<void (DebuggerParser*)> executor;
}; };
using CommandArray = std::array<Command, 102>; using CommandArray = std::array<Command, 103>;
static CommandArray commands; static CommandArray commands;
struct Trap struct Trap
@ -150,6 +150,7 @@ class DebuggerParser
// List of available command methods // List of available command methods
void executeA(); void executeA();
void executeAud(); void executeAud();
void executeAutoSave();
void executeBase(); void executeBase();
void executeBCol(); void executeBCol();
void executeBreak(); void executeBreak();

View File

@ -386,8 +386,22 @@ void PromptWidget::loadConfig()
print(instance().debugger().cartDebug().loadConfigFile() + "\n"); print(instance().debugger().cartDebug().loadConfigFile() + "\n");
print(instance().debugger().cartDebug().loadListFile() + "\n"); print(instance().debugger().cartDebug().loadListFile() + "\n");
print(instance().debugger().cartDebug().loadSymbolFile() + "\n"); print(instance().debugger().cartDebug().loadSymbolFile() + "\n");
bool extra = false;
if(instance().settings().getBool("dbg.autosave"))
{
print(DebuggerParser::inverse(" autoSave enabled "));
print("\177 "); // must switch inverse here!
extra = true;
}
if(instance().settings().getBool("dbg.logbreaks")) if(instance().settings().getBool("dbg.logbreaks"))
print(DebuggerParser::inverse(" logBreaks enabled \n")); {
print(DebuggerParser::inverse(" logBreaks enabled "));
extra = true;
}
if(extra)
print("\n");
print(PROMPT); print(PROMPT);
_promptStartPos = _promptEndPos = _currentPos; _promptStartPos = _promptEndPos = _currentPos;

View File

@ -189,6 +189,7 @@ Settings::Settings()
setPermanent("dbg.uhex", "false"); setPermanent("dbg.uhex", "false");
setPermanent("dbg.ghostreadstrap", "true"); setPermanent("dbg.ghostreadstrap", "true");
setPermanent("dbg.logbreaks", "false"); setPermanent("dbg.logbreaks", "false");
setPermanent("dbg.autosave", "false");
setPermanent("dis.resolve", "true"); setPermanent("dis.resolve", "true");
setPermanent("dis.gfxformat", "2"); setPermanent("dis.gfxformat", "2");
setPermanent("dis.showaddr", "true"); setPermanent("dis.showaddr", "true");
@ -614,8 +615,9 @@ void Settings::usage() const
<< " -dbg.fontstyle <0-3> Font style to use in debugger window (bold vs.\n" << " -dbg.fontstyle <0-3> Font style to use in debugger window (bold vs.\n"
<< " normal)\n" << " normal)\n"
<< " -dbg.ghostreadstrap <1|0> Debugger traps on 'ghost' reads\n" << " -dbg.ghostreadstrap <1|0> Debugger traps on 'ghost' reads\n"
<< " -dbg.uhex <0|1> lower-/uppercase HEX display\n" << " -dbg.uhex <0|1> Lower-/uppercase HEX display\n"
<< " -dbg.logbreaks <0|1> log breaks and traps and continue emulation\n" << " -dbg.logbreaks <0|1> Log breaks and traps and continue emulation\n"
<< " -dbg.autosave <0|1> Automatically save breaks, traps etc.\n"
<< " -break <address> Set a breakpoint at 'address'\n" << " -break <address> Set a breakpoint at 'address'\n"
<< " -debug Start in debugger mode\n" << " -debug Start in debugger mode\n"
<< endl << endl