fix #393 by using one-shot breakpoints

This commit is contained in:
Thomas Jentzsch 2019-08-13 17:27:23 +02:00
parent c769d22b54
commit c68e8f1c30
6 changed files with 32 additions and 19 deletions

View File

@ -196,6 +196,12 @@ PackedBitArray& Debugger::breakPoints() const
return mySystem.m6502().breakPoints();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PackedBitArray& Debugger::breakPointFlags() const
{
return mySystem.m6502().breakPointFlags();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TrapArray& Debugger::readTraps() const
{
@ -329,8 +335,18 @@ int Debugger::trace()
uInt64 startCycle = mySystem.cycles();
int targetPC = myCpuDebug->pc() + 3; // return address
// set temporary breakpoint at target PC (if not existing already)
breakPoints().initialize();
if(!breakPoints().isSet(targetPC))
{
breakPoints().set(targetPC);
breakPointFlags().initialize();
breakPointFlags().set(targetPC);
}
unlockSystem();
myOSystem.console().tia().updateScanlineByTrace(targetPC).flushLineCache();
mySystem.m6502().execute(11900000); // max. ~10 seconds
myOSystem.console().tia().flushLineCache();
lockSystem();
addState("trace");
@ -345,6 +361,7 @@ void Debugger::toggleBreakPoint(uInt16 bp)
{
breakPoints().initialize();
breakPoints().toggle(bp);
breakPointFlags().initialize();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -353,6 +370,7 @@ void Debugger::setBreakPoint(uInt16 bp, bool set)
breakPoints().initialize();
if(set) breakPoints().set(bp);
else breakPoints().clear(bp);
breakPointFlags().initialize();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -150,6 +150,7 @@ class Debugger : public DialogContainer
TiaOutputWidget& tiaOutput() const { return myDialog->tiaOutput(); }
PackedBitArray& breakPoints() const;
PackedBitArray& breakPointFlags() const;
TrapArray& readTraps() const;
TrapArray& writeTraps() const;

View File

@ -282,7 +282,14 @@ inline void M6502::_execute(uInt64 cycles, DispatchResult& result)
if(myBreakPoints.isInitialized() && myBreakPoints.isSet(PC)) {
myLastBreakCycle = mySystem->cycles();
result.setDebugger(currentCycles, "BP: ", PC);
// disable a one-shot breakpoint
if(myBreakPoints.isInitialized() && myBreakPointFlags.isSet(PC))
{
myBreakPoints.clear(PC);
myBreakPointFlags.clear(PC);
}
else
result.setDebugger(currentCycles, "BP: ", PC);
return;
}

View File

@ -213,6 +213,8 @@ class M6502 : public Serializable
void attach(Debugger& debugger);
PackedBitArray& breakPoints() { return myBreakPoints; }
// flags used for one-shot breakpoints
PackedBitArray& breakPointFlags() { return myBreakPointFlags; }
TrapArray& readTraps() { return myReadTraps; }
TrapArray& writeTraps() { return myWriteTraps; }
@ -426,7 +428,8 @@ class M6502 : public Serializable
Debugger* myDebugger;
// Addresses for which the specified action should occur
PackedBitArray myBreakPoints;// , myReadTraps, myWriteTraps, myReadTrapIfs, myWriteTrapIfs;
PackedBitArray myBreakPoints;
PackedBitArray myBreakPointFlags;
TrapArray myReadTraps, myWriteTraps;
// Did we just now hit a trap?

View File

@ -1171,16 +1171,6 @@ TIA& TIA::updateScanlineByStep()
return *this;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TIA& TIA::updateScanlineByTrace(int target)
{
uInt32 count = 10000; // only try up to 10000 steps
while (mySystem->m6502().getPC() != target && count-- &&
mySystem->m6502().execute(1));
return *this;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 TIA::registerValue(uInt8 reg) const
{

View File

@ -471,12 +471,6 @@ class TIA : public Device
*/
TIA& updateScanlineByStep();
/**
This method should be called to update the TIA with a new partial
scanline by tracing to target address.
*/
TIA& updateScanlineByTrace(int target);
/**
Retrieve the last value written to a certain register.
*/