Fix spurious failures of debugger breakpoints.

This commit is contained in:
Christian Speckner 2018-08-06 17:51:47 +02:00
parent 573d9a1e25
commit 86a242a8cf
2 changed files with 12 additions and 1 deletions

View File

@ -118,6 +118,8 @@ void M6502::reset()
myHaltRequested = false; myHaltRequested = false;
myGhostReadsTrap = mySettings.getBool("dbg.ghostreadstrap"); myGhostReadsTrap = mySettings.getBool("dbg.ghostreadstrap");
myLastBreakCycle = -1;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -259,17 +261,19 @@ inline void M6502::_execute(uInt64 cycles, DispatchResult& result)
{ {
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
// Don't break if we haven't actually executed anything yet // Don't break if we haven't actually executed anything yet
if (currentCycles > 0) { if (myLastBreakCycle != mySystem->cycles()) {
if(myJustHitReadTrapFlag || myJustHitWriteTrapFlag) if(myJustHitReadTrapFlag || myJustHitWriteTrapFlag)
{ {
bool read = myJustHitReadTrapFlag; bool read = myJustHitReadTrapFlag;
myJustHitReadTrapFlag = myJustHitWriteTrapFlag = false; myJustHitReadTrapFlag = myJustHitWriteTrapFlag = false;
myLastBreakCycle = mySystem->cycles();
result.setDebugger(currentCycles, myHitTrapInfo.message, myHitTrapInfo.address, read); result.setDebugger(currentCycles, myHitTrapInfo.message, myHitTrapInfo.address, read);
return; return;
} }
if(myBreakPoints.isInitialized() && myBreakPoints.isSet(PC)) { if(myBreakPoints.isInitialized() && myBreakPoints.isSet(PC)) {
myLastBreakCycle = mySystem->cycles();
result.setDebugger(currentCycles, "BP: ", PC); result.setDebugger(currentCycles, "BP: ", PC);
return; return;
} }
@ -280,6 +284,7 @@ inline void M6502::_execute(uInt64 cycles, DispatchResult& result)
stringstream msg; stringstream msg;
msg << "CBP[" << Common::Base::HEX2 << cond << "]: " << myCondBreakNames[cond]; msg << "CBP[" << Common::Base::HEX2 << cond << "]: " << myCondBreakNames[cond];
myLastBreakCycle = mySystem->cycles();
result.setDebugger(currentCycles, msg.str()); result.setDebugger(currentCycles, msg.str());
return; return;
} }
@ -432,6 +437,7 @@ bool M6502::save(Serializer& out) const
out.putBool(myHaltRequested); out.putBool(myHaltRequested);
out.putBool(myStepStateByInstruction); out.putBool(myStepStateByInstruction);
out.putBool(myGhostReadsTrap); out.putBool(myGhostReadsTrap);
out.putLong(myLastBreakCycle);
} }
catch(...) catch(...)
{ {
@ -484,6 +490,8 @@ bool M6502::load(Serializer& in)
myHaltRequested = in.getBool(); myHaltRequested = in.getBool();
myStepStateByInstruction = in.getBool(); myStepStateByInstruction = in.getBool();
myGhostReadsTrap = in.getBool(); myGhostReadsTrap = in.getBool();
myLastBreakCycle = in.getLong();
} }
catch(...) catch(...)
{ {

View File

@ -377,6 +377,9 @@ class M6502 : public Serializable
/// Indicates the last address which was accessed /// Indicates the last address which was accessed
uInt16 myLastAddress; uInt16 myLastAddress;
/// Last cycle that triggered a breakpoint
uInt64 myLastBreakCycle;
/// Indicates the last address which was accessed specifically /// Indicates the last address which was accessed specifically
/// by a peek or poke command /// by a peek or poke command
uInt16 myLastPeekAddress, myLastPokeAddress; uInt16 myLastPeekAddress, myLastPokeAddress;