display write destination address in debugger (implements #74)

This commit is contained in:
thrust26 2020-03-26 13:48:46 +01:00
parent 6741cb4ef9
commit 193e8a1a46
11 changed files with 63 additions and 16 deletions

View File

@ -156,6 +156,18 @@ void CartDebug::saveOldState()
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartDebug::lastReadAddress()
{
return mySystem.m6502().lastReadAddress();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartDebug::lastWriteAddress()
{
return mySystem.m6502().lastWriteAddress();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartDebug::lastReadBaseAddress()
{

View File

@ -104,6 +104,12 @@ class CartDebug : public DebuggerSystem
CartDebugWidget* getDebugWidget() const { return myDebugWidget; }
void setDebugWidget(CartDebugWidget* w) { myDebugWidget = w; }
// Return the address of the last CPU read
int lastReadAddress();
// Return the address of the last CPU write
int lastWriteAddress();
// Return the base (= non-mirrored) address of the last CPU read
int lastReadBaseAddress();
// Return the base (= non-mirrored) address of the last CPU write

View File

@ -46,6 +46,7 @@ const DebuggerState& CpuDebug::getState()
myState.srcA = my6502.lastSrcAddressA();
myState.srcX = my6502.lastSrcAddressX();
myState.srcY = my6502.lastSrcAddressY();
myState.dest = my6502.lastWriteAddress();
Debugger::set_bits(myState.PS, myState.PSbits);
@ -66,6 +67,7 @@ void CpuDebug::saveOldState()
myOldState.srcA = my6502.lastSrcAddressA();
myOldState.srcX = my6502.lastSrcAddressX();
myOldState.srcY = my6502.lastSrcAddressY();
myOldState.dest = my6502.lastWriteAddress();
Debugger::set_bits(myOldState.PS, myOldState.PSbits);
}

View File

@ -31,7 +31,7 @@ class CpuState : public DebuggerState
{
public:
int PC{0}, SP{0}, PS{0}, A{0}, X{0}, Y{0};
int srcS{0}, srcA{0}, srcX{0}, srcY{0};
int srcS{0}, srcA{0}, srcX{0}, srcY{0}, dest{0};
BoolArray PSbits;
};

View File

@ -887,6 +887,8 @@ std::array<Debugger::PseudoRegister, 11> Debugger::ourPseudoRegisters = { {
{ "_vblank", "Whether vertical blank is enabled (1 or 0)" },
{ "_vsync", "Whether vertical sync is enabled (1 or 0)" }
// CPU address access functions:
/*{ "__lastread", "last CPU read address" },
{ "__lastwrite", "last CPU write address" },*/
/*{ "_lastread", "last CPU read address" },
{ "_lastwrite", "last CPU write address" },
{ "__lastbaseread", "last CPU read base address" },
{ "__lastbasewrite", "last CPU write base address" }*/
} };

View File

@ -2054,18 +2054,18 @@ void DebuggerParser::executeTraps(bool read, bool write, const string& command,
if(read)
{
if(beginRead != endRead)
conditionBuf << "__lastread>=" << Base::toString(beginRead) << "&&__lastread<=" << Base::toString(endRead);
conditionBuf << "__lastbaseread>=" << Base::toString(beginRead) << "&&__lastbaseread<=" << Base::toString(endRead);
else
conditionBuf << "__lastread==" << Base::toString(beginRead);
conditionBuf << "__lastbaseread==" << Base::toString(beginRead);
}
if(read && write)
conditionBuf << "||";
if(write)
{
if(beginWrite != endWrite)
conditionBuf << "__lastwrite>=" << Base::toString(beginWrite) << "&&__lastwrite<=" << Base::toString(endWrite);
conditionBuf << "__lastbasewrite>=" << Base::toString(beginWrite) << "&&__lastbasewrite<=" << Base::toString(endWrite);
else
conditionBuf << "__lastwrite==" << Base::toString(beginWrite);
conditionBuf << "__lastbasewrite==" << Base::toString(beginWrite);
}
// parenthesize provided condition (end)
if(hasCond)

View File

@ -93,10 +93,11 @@ CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n
myCpuDataSrc[i]->setEditable(false, true);
src_y += fontHeight+2;
}
int swidth = lfont.getStringWidth("Source Address");
new StaticTextWidget(boss, lfont, xpos, src_y + 4, src_w,
fontHeight, swidth <= src_w ? "Source Address" : "Source Addr",
TextAlign::Center);
// Last write destination address
new StaticTextWidget(boss, lfont, xpos - fontWidth * 4.5, src_y + 4, "Dest");
myCpuDataDest = new EditTextWidget(boss, nfont, xpos, src_y + 2, src_w, fontHeight+1);
myCpuDataDest->setEditable(false, true);
// Add labels for other CPU registers
xpos = x;
@ -325,6 +326,10 @@ void CpuWidget::loadConfig()
myCpuDataSrc[3]->setText((srcY != EmptyString ? srcY : Common::Base::toString(state.srcY)),
state.srcY != oldstate.srcY);
const string& dest = state.dest < 0 ? "" : cart.getLabel(state.dest, false);
myCpuDataDest->setText((srcY != EmptyString ? dest : Common::Base::toString(state.dest)),
state.dest != oldstate.dest);
// Update the PS register booleans
changed.clear();
for(uInt32 i = 0; i < state.PSbits.size(); ++i)

View File

@ -76,6 +76,7 @@ class CpuWidget : public Widget, public CommandSender
ToggleBitWidget* myPSRegister{nullptr};
EditTextWidget* myPCLabel{nullptr};
std::array<EditTextWidget*, 4> myCpuDataSrc{nullptr};
EditTextWidget* myCpuDataDest{nullptr};
private:
// Following constructors and assignment operators not supported

View File

@ -300,8 +300,8 @@ inline void M6502::_execute(uInt64 cycles, DispatchResult& result)
mySystem->cart().clearAllRAMAccesses();
#endif // DEBUGGER_SUPPORT
// Reset the peek/poke address pointers
myLastPeekAddress = myLastPokeAddress = myDataAddressForPoke = 0;
// Reset the data poke address pointer
myDataAddressForPoke = 0;
try {
uInt16 operandAddress = 0, intermediateAddress = 0;

View File

@ -156,13 +156,27 @@ class M6502 : public Serializable
@return The address of the last read
*/
uInt16 lastReadBaseAddress() const { return myLastPeekBaseAddress; }
uInt16 lastReadAddress() const { return myLastPeekAddress; }
/**
Return the last address that was part of a write/poke.
@return The address of the last write
*/
uInt16 lastWriteAddress() const { return myLastPokeAddress; }
/**
Return the last (non-mirrored) address that was part of a read/peek.
@return The address of the last read
*/
uInt16 lastReadBaseAddress() const { return myLastPeekBaseAddress; }
/**
Return the last (non-mirrored) address that was part of a write/poke.
@return The address of the last write
*/
uInt16 lastWriteBaseAddress() const { return myLastPokeBaseAddress; }
/**

View File

@ -181,10 +181,15 @@ CartMethod getCartSpecial(char* ch)
{
if(BSPF::equalsIgnoreCase(ch, "_bank"))
return &CartDebug::getPCBank;
else if(BSPF::equalsIgnoreCase(ch, "__lastread"))
else if(BSPF::equalsIgnoreCase(ch, "__lastbaseread"))
return &CartDebug::lastReadBaseAddress;
else if(BSPF::equalsIgnoreCase(ch, "__lastwrite"))
else if(BSPF::equalsIgnoreCase(ch, "__lastbasewrite"))
return &CartDebug::lastWriteBaseAddress;
else if(BSPF::equalsIgnoreCase(ch, "__lastread"))
return &CartDebug::lastReadAddress;
else if(BSPF::equalsIgnoreCase(ch, "__lastwrite"))
return &CartDebug::lastWriteAddress;
else
return nullptr;
}