double rewind in debugger fixed

rewind messages improved
This commit is contained in:
thrust26 2017-12-12 18:47:21 +01:00
parent fc01aef34e
commit 6632b97307
4 changed files with 21 additions and 35 deletions

View File

@ -134,13 +134,15 @@ bool RewindManager::rewindState()
{ {
if(!atFirst()) if(!atFirst())
{ {
RewindState& lastState = myStateList.current();
// Set internal current iterator to previous state (back in time), // Set internal current iterator to previous state (back in time),
// since we will now processed this state // since we will now processed this state
myStateList.moveToPrevious(); myStateList.moveToPrevious();
RewindState& state = myStateList.current(); RewindState& state = myStateList.current();
Serializer& s = state.data; Serializer& s = state.data;
string message = getMessage(state); string message = getMessage(state, lastState);
cerr << "rewind " << state.count << endl; cerr << "rewind " << state.count << endl;
s.rewind(); // rewind Serializer internal buffers s.rewind(); // rewind Serializer internal buffers
@ -166,7 +168,7 @@ bool RewindManager::unwindState()
RewindState& state = myStateList.current(); RewindState& state = myStateList.current();
Serializer& s = state.data; Serializer& s = state.data;
string message = getMessage(state); string message = getMessage(state, state);
cerr << "unwind " << state.count << endl; cerr << "unwind " << state.count << endl;
s.rewind(); // rewind Serializer internal buffers s.rewind(); // rewind Serializer internal buffers
@ -232,7 +234,7 @@ cerr << "remove " << removeIdx << endl;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string RewindManager::getMessage(RewindState& state) string RewindManager::getMessage(RewindState& state, RewindState& lastState)
{ {
Int64 diff = myOSystem.console().tia().cycles() - state.cycle; Int64 diff = myOSystem.console().tia().cycles() - state.cycle;
stringstream message; stringstream message;
@ -240,8 +242,8 @@ string RewindManager::getMessage(RewindState& state)
message << (diff >= 0 ? "Rewind" : "Unwind") << " " << getUnitString(diff); message << (diff >= 0 ? "Rewind" : "Unwind") << " " << getUnitString(diff);
// add optional message (TODO: when smart removal works, we have to do something smart with this part too) // add optional message (TODO: when smart removal works, we have to do something smart with this part too)
if(!state.message.empty()) if(!lastState.message.empty())
message << " (" << state.message << ")"; message << " (" << lastState.message << ")";
return message.str(); return message.str();
} }

View File

@ -167,7 +167,7 @@ class RewindManager
void compressStates(); void compressStates();
string getMessage(RewindState& state); string getMessage(RewindState& state, RewindState& lastState);
private: private:
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported

View File

@ -270,7 +270,6 @@ void Debugger::loadState(int state)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Debugger::step() int Debugger::step()
{ {
saveOldState("1 step");
mySystem.clearDirtyPages(); mySystem.clearDirtyPages();
uInt64 startCycle = mySystem.cycles(); uInt64 startCycle = mySystem.cycles();
@ -279,6 +278,7 @@ int Debugger::step()
myOSystem.console().tia().updateScanlineByStep().flushLineCache(); myOSystem.console().tia().updateScanlineByStep().flushLineCache();
lockBankswitchState(); lockBankswitchState();
saveOldState("step");
return int(mySystem.cycles() - startCycle); return int(mySystem.cycles() - startCycle);
} }
@ -297,7 +297,6 @@ int Debugger::trace()
// 32 is the 6502 JSR instruction: // 32 is the 6502 JSR instruction:
if(mySystem.peek(myCpuDebug->pc()) == 32) if(mySystem.peek(myCpuDebug->pc()) == 32)
{ {
saveOldState("1 trace");
mySystem.clearDirtyPages(); mySystem.clearDirtyPages();
uInt64 startCycle = mySystem.cycles(); uInt64 startCycle = mySystem.cycles();
@ -307,6 +306,7 @@ int Debugger::trace()
myOSystem.console().tia().updateScanlineByTrace(targetPC).flushLineCache(); myOSystem.console().tia().updateScanlineByTrace(targetPC).flushLineCache();
lockBankswitchState(); lockBankswitchState();
saveOldState("trace");
return int(mySystem.cycles() - startCycle); return int(mySystem.cycles() - startCycle);
} }
else else
@ -483,11 +483,8 @@ uInt32 Debugger::getBaseAddress(uInt32 addr, bool read)
void Debugger::nextScanline(int lines) void Debugger::nextScanline(int lines)
{ {
ostringstream buf; ostringstream buf;
buf << lines << " scanline"; buf << "scanline + " << lines;
if(lines > 1)
buf << "s";
saveOldState(buf.str());
mySystem.clearDirtyPages(); mySystem.clearDirtyPages();
unlockBankswitchState(); unlockBankswitchState();
@ -498,6 +495,7 @@ void Debugger::nextScanline(int lines)
} }
lockBankswitchState(); lockBankswitchState();
saveOldState(buf.str());
myOSystem.console().tia().flushLineCache(); myOSystem.console().tia().flushLineCache();
} }
@ -505,11 +503,8 @@ void Debugger::nextScanline(int lines)
void Debugger::nextFrame(int frames) void Debugger::nextFrame(int frames)
{ {
ostringstream buf; ostringstream buf;
buf << frames << " frame"; buf << "frame + " << frames;
if(frames > 1)
buf << "s";
saveOldState(buf.str());
mySystem.clearDirtyPages(); mySystem.clearDirtyPages();
unlockBankswitchState(); unlockBankswitchState();
@ -519,6 +514,8 @@ void Debugger::nextFrame(int frames)
--frames; --frames;
} }
lockBankswitchState(); lockBankswitchState();
saveOldState(buf.str());
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -618,11 +615,8 @@ void Debugger::setStartState()
// Lock the bus each time the debugger is entered, so we don't disturb anything // Lock the bus each time the debugger is entered, so we don't disturb anything
lockBankswitchState(); lockBankswitchState();
RewindManager& r = myOSystem.state().rewindManager(); // Save initial state and add it to the rewind list
updateRewindbuttons(r); saveOldState("enter debugger");
// Save initial state, but don't add it to the rewind list
saveOldState();
// Set the 're-disassemble' flag, but don't do it until the next scheduled time // Set the 're-disassemble' flag, but don't do it until the next scheduled time
myDialog->rom().invalidate(false); myDialog->rom().invalidate(false);
@ -634,9 +628,6 @@ void Debugger::setQuitState()
// Bus must be unlocked for normal operation when leaving debugger mode // Bus must be unlocked for normal operation when leaving debugger mode
unlockBankswitchState(); unlockBankswitchState();
// Save state when leaving the debugger
saveOldState("exit debugger");
// execute one instruction on quit. If we're // execute one instruction on quit. If we're
// sitting at a breakpoint/trap, this will get us past it. // sitting at a breakpoint/trap, this will get us past it.
// Somehow this feels like a hack to me, but I don't know why // Somehow this feels like a hack to me, but I don't know why

View File

@ -143,7 +143,6 @@ void DeveloperDialog::addEmulationTab(const GUI::Font& font)
} }
ypos += lineHeight + VGAP; ypos += lineHeight + VGAP;
// How to handle undriven TIA pins // How to handle undriven TIA pins
myUndrivenPinsWidget = new CheckboxWidget(myTab, font, HBORDER + INDENT * 1, ypos + 1, myUndrivenPinsWidget = new CheckboxWidget(myTab, font, HBORDER + INDENT * 1, ypos + 1,
"Drive unused TIA pins randomly on a read/peek"); "Drive unused TIA pins randomly on a read/peek");
@ -214,9 +213,6 @@ void DeveloperDialog::addVideoTab(const GUI::Font& font)
wid.push_back(myDebugColorsWidget); wid.push_back(myDebugColorsWidget);
ypos += lineHeight + VGAP + 2; ypos += lineHeight + VGAP + 2;
//StaticTextWidget* s = new StaticTextWidget(myTab, font, HBORDER, ypos, "Debug Colors ");
//ypos += lineHeight + VGAP;
items.clear(); items.clear();
VarList::push_back(items, "Red", "r"); VarList::push_back(items, "Red", "r");
VarList::push_back(items, "Orange", "o"); VarList::push_back(items, "Orange", "o");
@ -521,8 +517,6 @@ void DeveloperDialog::loadSettings(SettingsSet set)
myContinuousRewind[set] = instance().settings().getBool(prefix + "rewind"); myContinuousRewind[set] = instance().settings().getBool(prefix + "rewind");
myStateSize[set] = instance().settings().getInt(prefix + "rewind.size"); myStateSize[set] = instance().settings().getInt(prefix + "rewind.size");
myUncompressed[set] = instance().settings().getInt(prefix + "rewind.uncompressed"); myUncompressed[set] = instance().settings().getInt(prefix + "rewind.uncompressed");
/*myStateInterval[set] = instance().settings().getInt(prefix + "rewind.interval");
myStateHorizon[set] = instance().settings().getInt(prefix + "rewind.horizon");*/
myStateInterval[set] = instance().settings().getString(prefix + "rewind.interval"); myStateInterval[set] = instance().settings().getString(prefix + "rewind.interval");
myStateHorizon[set] = instance().settings().getString(prefix + "rewind.horizon"); myStateHorizon[set] = instance().settings().getString(prefix + "rewind.horizon");
@ -631,9 +625,7 @@ void DeveloperDialog::setWidgetStates(SettingsSet set)
myContinuousRewindWidget->setState(myContinuousRewind[set]); myContinuousRewindWidget->setState(myContinuousRewind[set]);
myStateSizeWidget->setValue(myStateSize[set]); myStateSizeWidget->setValue(myStateSize[set]);
myUncompressedWidget->setValue(myUncompressed[set]); myUncompressedWidget->setValue(myUncompressed[set]);
//myStateIntervalWidget->setSelectedIndex(myStateInterval[set]);
myStateIntervalWidget->setSelected(myStateInterval[set]); myStateIntervalWidget->setSelected(myStateInterval[set]);
//myStateHorizonWidget->setSelectedIndex(myStateHorizon[set]);
myStateHorizonWidget->setSelected(myStateHorizon[set]); myStateHorizonWidget->setSelected(myStateHorizon[set]);
handleRewind(); handleRewind();
@ -726,16 +718,14 @@ void DeveloperDialog::saveConfig()
instance().state().setRewindMode(myContinuousRewindWidget->getState() ? instance().state().setRewindMode(myContinuousRewindWidget->getState() ?
StateManager::Mode::Rewind : StateManager::Mode::Off); StateManager::Mode::Rewind : StateManager::Mode::Off);
#ifdef DEBUGGER_SUPPORT
// Debugger font style // Debugger font style
instance().settings().setValue("dbg.fontstyle", instance().settings().setValue("dbg.fontstyle",
myDebuggerFontStyle->getSelectedTag().toString()); myDebuggerFontStyle->getSelectedTag().toString());
#ifdef DEBUGGER_SUPPORT
// Debugger size // Debugger size
instance().settings().setValue("dbg.res", instance().settings().setValue("dbg.res",
GUI::Size(myDebuggerWidthSlider->getValue(), GUI::Size(myDebuggerWidthSlider->getValue(),
myDebuggerHeightSlider->getValue())); myDebuggerHeightSlider->getValue()));
// Debugger font size // Debugger font size
instance().settings().setValue("dbg.fontsize", myDebuggerFontSize->getSelectedTag().toString()); instance().settings().setValue("dbg.fontsize", myDebuggerFontSize->getSelectedTag().toString());
#endif #endif
@ -982,6 +972,7 @@ void DeveloperDialog::handleSize()
bool found = false; bool found = false;
Int32 i; Int32 i;
// handle illegal values
if(interval == -1) if(interval == -1)
interval = 0; interval = 0;
if(horizon == -1) if(horizon == -1)
@ -1032,6 +1023,7 @@ void DeveloperDialog::handleInterval()
bool found = false; bool found = false;
Int32 i; Int32 i;
// handle illegal values
if(interval == -1) if(interval == -1)
interval = 0; interval = 0;
if(horizon == -1) if(horizon == -1)
@ -1069,6 +1061,7 @@ void DeveloperDialog::handleHorizon()
bool found = false; bool found = false;
Int32 i; Int32 i;
// handle illegal values
if(interval == -1) if(interval == -1)
interval = 0; interval = 0;
if(horizon == -1) if(horizon == -1)