rewind/unwind commands enhanced with optional number of levels parameter

This commit is contained in:
thrust26 2017-11-13 15:07:48 +01:00
parent 3f77b95b3b
commit 92a8747eb3
4 changed files with 50 additions and 31 deletions

View File

@ -458,30 +458,37 @@ void Debugger::updateRewindbuttons(const RewindManager& r)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::windState(bool unwind) uInt16 Debugger::windStates(uInt16 levels, bool unwind)
{ {
RewindManager& r = myOSystem.state().rewindManager(); RewindManager& r = myOSystem.state().rewindManager();
mySystem.clearDirtyPages(); mySystem.clearDirtyPages();
unlockBankswitchState(); unlockBankswitchState();
bool result = unwind ? r.unwindState() : r.rewindState();
uInt16 winds = 0;
for(uInt16 i = 0; i < levels; ++i)
if(unwind ? r.unwindState() : r.rewindState())
winds++;
else
break;
lockBankswitchState(); lockBankswitchState();
updateRewindbuttons(r); updateRewindbuttons(r);
return result; return winds;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::rewindState() uInt16 Debugger::rewindStates(const uInt16 levels)
{ {
return windState(false); return windStates(levels, false);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::unwindState() uInt16 Debugger::unwindStates(const uInt16 levels)
{ {
return windState(true); return windStates(levels, true);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -270,8 +270,8 @@ class Debugger : public DialogContainer
int trace(); int trace();
void nextScanline(int lines); void nextScanline(int lines);
void nextFrame(int frames); void nextFrame(int frames);
bool rewindState(); uInt16 rewindStates(const uInt16 levels);
bool unwindState(); uInt16 unwindStates(const uInt16 levels);
void toggleBreakPoint(uInt16 bp); void toggleBreakPoint(uInt16 bp);
@ -328,8 +328,8 @@ class Debugger : public DialogContainer
static PseudoRegister ourPseudoRegisters[NUM_PSEUDO_REGS]; static PseudoRegister ourPseudoRegisters[NUM_PSEUDO_REGS];
private: private:
// rewind/unwind one state // rewind/unwind n states
bool windState(bool unwind); uInt16 windStates(uInt16 levels, bool unwind);
// update the rewind/unwind button state // update the rewind/unwind button state
void updateRewindbuttons(const RewindManager& r); void updateRewindbuttons(const RewindManager& r);

View File

@ -1335,13 +1335,7 @@ void DebuggerParser::executeReset()
// "rewind" // "rewind"
void DebuggerParser::executeRewind() void DebuggerParser::executeRewind()
{ {
if(debugger.rewindState()) executeWinds(false);
{
debugger.rom().invalidate();
commandResult << "rewind by one level";
}
else
commandResult << "no states left to rewind";
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1843,13 +1837,7 @@ void DebuggerParser::executeUndef()
// "unwind" // "unwind"
void DebuggerParser::executeUnwind() void DebuggerParser::executeUnwind()
{ {
if(debugger.unwindState()) executeWinds(true);
{
debugger.rom().invalidate();
commandResult << "unwind by one level";
}
else
commandResult << "no states left to rewind";
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1870,6 +1858,29 @@ void DebuggerParser::executeWatch()
commandResult << "added watch \"" << argStrings[0] << "\""; commandResult << "added watch \"" << argStrings[0] << "\"";
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// wrapper function for rewind/unwind commands
// TODO: return and output (formatted) cycles
void DebuggerParser::executeWinds(bool unwind)
{
uInt16 levels;
string type = unwind ? "unwind" : "rewind";
if(argCount == 0)
levels = 1;
else
levels = args[0];
uInt16 winds = unwind ? debugger.unwindStates(levels) : debugger.rewindStates(levels);
if(winds > 0)
{
debugger.rom().invalidate();
commandResult << type << " by " << winds << " level" << (winds > 1 ? "s" : "");
}
else
commandResult << "no states left to " << type;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "x" // "x"
void DebuggerParser::executeX() void DebuggerParser::executeX()
@ -2335,11 +2346,11 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"rewind", "rewind",
"Rewind state to last step/trace/scanline/frame", "Rewind state to last step/trace/scanline/frame...",
"Rewind currently only works in the debugger", "Example: rewind, rewind 5",
false, false,
true, true,
{ kARG_END_ARGS }, { kARG_WORD, kARG_END_ARGS },
std::mem_fn(&DebuggerParser::executeRewind) std::mem_fn(&DebuggerParser::executeRewind)
}, },
@ -2628,11 +2639,11 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"unwind", "unwind",
"Unwind state to last step/trace/scanline/frame", "Unwind state to next step/trace/scanline/frame...",
"Unwind currently only works in the debugger", "Example: unwind, unwind 5",
false, false,
true, true,
{ kARG_END_ARGS }, { kARG_WORD, kARG_END_ARGS },
std::mem_fn(&DebuggerParser::executeUnwind) std::mem_fn(&DebuggerParser::executeUnwind)
}, },

View File

@ -212,6 +212,7 @@ class DebuggerParser
void executeUnwind(); void executeUnwind();
void executeV(); void executeV();
void executeWatch(); void executeWatch();
void executeWinds(bool unwind);
void executeX(); void executeX();
void executeY(); void executeY();
void executeZ(); void executeZ();