diff --git a/src/debugger/Debugger.cxx b/src/debugger/Debugger.cxx index b9d94e04b..209ed3eec 100644 --- a/src/debugger/Debugger.cxx +++ b/src/debugger/Debugger.cxx @@ -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(); mySystem.clearDirtyPages(); 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(); 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); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/Debugger.hxx b/src/debugger/Debugger.hxx index 5aa5ded43..f6d47890f 100644 --- a/src/debugger/Debugger.hxx +++ b/src/debugger/Debugger.hxx @@ -270,8 +270,8 @@ class Debugger : public DialogContainer int trace(); void nextScanline(int lines); void nextFrame(int frames); - bool rewindState(); - bool unwindState(); + uInt16 rewindStates(const uInt16 levels); + uInt16 unwindStates(const uInt16 levels); void toggleBreakPoint(uInt16 bp); @@ -328,8 +328,8 @@ class Debugger : public DialogContainer static PseudoRegister ourPseudoRegisters[NUM_PSEUDO_REGS]; private: - // rewind/unwind one state - bool windState(bool unwind); + // rewind/unwind n states + uInt16 windStates(uInt16 levels, bool unwind); // update the rewind/unwind button state void updateRewindbuttons(const RewindManager& r); diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index 498ad763c..8eb24138b 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -1335,13 +1335,7 @@ void DebuggerParser::executeReset() // "rewind" void DebuggerParser::executeRewind() { - if(debugger.rewindState()) - { - debugger.rom().invalidate(); - commandResult << "rewind by one level"; - } - else - commandResult << "no states left to rewind"; + executeWinds(false); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1843,13 +1837,7 @@ void DebuggerParser::executeUndef() // "unwind" void DebuggerParser::executeUnwind() { - if(debugger.unwindState()) - { - debugger.rom().invalidate(); - commandResult << "unwind by one level"; - } - else - commandResult << "no states left to rewind"; + executeWinds(true); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1870,6 +1858,29 @@ void DebuggerParser::executeWatch() 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" void DebuggerParser::executeX() @@ -2335,11 +2346,11 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = { { "rewind", - "Rewind state to last step/trace/scanline/frame", - "Rewind currently only works in the debugger", + "Rewind state to last step/trace/scanline/frame...", + "Example: rewind, rewind 5", false, true, - { kARG_END_ARGS }, + { kARG_WORD, kARG_END_ARGS }, std::mem_fn(&DebuggerParser::executeRewind) }, @@ -2628,11 +2639,11 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = { { "unwind", - "Unwind state to last step/trace/scanline/frame", - "Unwind currently only works in the debugger", + "Unwind state to next step/trace/scanline/frame...", + "Example: unwind, unwind 5", false, true, - { kARG_END_ARGS }, + { kARG_WORD, kARG_END_ARGS }, std::mem_fn(&DebuggerParser::executeUnwind) }, diff --git a/src/debugger/DebuggerParser.hxx b/src/debugger/DebuggerParser.hxx index 3aa977eef..196121b04 100644 --- a/src/debugger/DebuggerParser.hxx +++ b/src/debugger/DebuggerParser.hxx @@ -212,6 +212,7 @@ class DebuggerParser void executeUnwind(); void executeV(); void executeWatch(); + void executeWinds(bool unwind); void executeX(); void executeY(); void executeZ();