From 86a242a8cf0c1eb95bc65038c4dca37db1505e04 Mon Sep 17 00:00:00 2001 From: Christian Speckner Date: Mon, 6 Aug 2018 17:51:47 +0200 Subject: [PATCH] Fix spurious failures of debugger breakpoints. --- src/emucore/M6502.cxx | 10 +++++++++- src/emucore/M6502.hxx | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/emucore/M6502.cxx b/src/emucore/M6502.cxx index d9497cb7d..39bd4a1b4 100644 --- a/src/emucore/M6502.cxx +++ b/src/emucore/M6502.cxx @@ -118,6 +118,8 @@ void M6502::reset() myHaltRequested = false; myGhostReadsTrap = mySettings.getBool("dbg.ghostreadstrap"); + + myLastBreakCycle = -1; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -259,17 +261,19 @@ inline void M6502::_execute(uInt64 cycles, DispatchResult& result) { #ifdef DEBUGGER_SUPPORT // Don't break if we haven't actually executed anything yet - if (currentCycles > 0) { + if (myLastBreakCycle != mySystem->cycles()) { if(myJustHitReadTrapFlag || myJustHitWriteTrapFlag) { bool read = myJustHitReadTrapFlag; myJustHitReadTrapFlag = myJustHitWriteTrapFlag = false; + myLastBreakCycle = mySystem->cycles(); result.setDebugger(currentCycles, myHitTrapInfo.message, myHitTrapInfo.address, read); return; } if(myBreakPoints.isInitialized() && myBreakPoints.isSet(PC)) { + myLastBreakCycle = mySystem->cycles(); result.setDebugger(currentCycles, "BP: ", PC); return; } @@ -280,6 +284,7 @@ inline void M6502::_execute(uInt64 cycles, DispatchResult& result) stringstream msg; msg << "CBP[" << Common::Base::HEX2 << cond << "]: " << myCondBreakNames[cond]; + myLastBreakCycle = mySystem->cycles(); result.setDebugger(currentCycles, msg.str()); return; } @@ -432,6 +437,7 @@ bool M6502::save(Serializer& out) const out.putBool(myHaltRequested); out.putBool(myStepStateByInstruction); out.putBool(myGhostReadsTrap); + out.putLong(myLastBreakCycle); } catch(...) { @@ -484,6 +490,8 @@ bool M6502::load(Serializer& in) myHaltRequested = in.getBool(); myStepStateByInstruction = in.getBool(); myGhostReadsTrap = in.getBool(); + + myLastBreakCycle = in.getLong(); } catch(...) { diff --git a/src/emucore/M6502.hxx b/src/emucore/M6502.hxx index 5504a5366..98fb45b5e 100644 --- a/src/emucore/M6502.hxx +++ b/src/emucore/M6502.hxx @@ -377,6 +377,9 @@ class M6502 : public Serializable /// Indicates the last address which was accessed uInt16 myLastAddress; + /// Last cycle that triggered a breakpoint + uInt64 myLastBreakCycle; + /// Indicates the last address which was accessed specifically /// by a peek or poke command uInt16 myLastPeekAddress, myLastPokeAddress;