From 90705babd7f84ce69764ac75505a9dd0b995c862 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Sun, 8 Oct 2017 12:25:23 +0200 Subject: [PATCH] debugger start displays labels where possible prevent repeated trap interrupts some old code cleanup --- src/debugger/Debugger.cxx | 26 ++------------------------ src/debugger/Debugger.hxx | 7 +------ src/debugger/DebuggerParser.cxx | 1 + src/emucore/M6502.cxx | 24 ++++++++++++------------ src/emucore/M6502.hxx | 3 ++- 5 files changed, 18 insertions(+), 43 deletions(-) diff --git a/src/debugger/Debugger.cxx b/src/debugger/Debugger.cxx index 50dc315ae..1698efbb3 100644 --- a/src/debugger/Debugger.cxx +++ b/src/debugger/Debugger.cxx @@ -168,7 +168,7 @@ FBInitStatus Debugger::initializeVideo() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Debugger::start(const string& message, int address) +bool Debugger::start(const string& message, int address, bool read) { if(myOSystem.eventHandler().enterDebugMode()) { @@ -177,8 +177,7 @@ bool Debugger::start(const string& message, int address) ostringstream buf; buf << message; if(address > -1) - buf << Common::Base::HEX4 << address; - + buf << cartDebug().getLabel(address, read); myDialog->message().setText(buf.str()); return true; } @@ -368,27 +367,6 @@ bool Debugger::breakPoint(uInt16 bp) return breakPoints().isSet(bp); } -/*// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Debugger::toggleReadTrap(uInt16 t) -{ - readTraps().initialize(); - readTraps().toggle(t); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Debugger::toggleWriteTrap(uInt16 t) -{ - writeTraps().initialize(); - writeTraps().toggle(t); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Debugger::toggleTrap(uInt16 t) -{ - toggleReadTrap(t); - toggleWriteTrap(t); -}*/ - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Debugger::addReadTrap(uInt16 t) { diff --git a/src/debugger/Debugger.hxx b/src/debugger/Debugger.hxx index 118a33558..635e953ae 100644 --- a/src/debugger/Debugger.hxx +++ b/src/debugger/Debugger.hxx @@ -88,7 +88,7 @@ class Debugger : public DialogContainer @param message Message to display when entering debugger @param address An address associated with the message */ - bool start(const string& message = "", int address = -1); + bool start(const string& message = "", int address = -1, bool read = true); bool startWithFatalError(const string& message = ""); /** @@ -147,8 +147,6 @@ class Debugger : public DialogContainer PackedBitArray& breakPoints() const { return mySystem.m6502().breakPoints(); } TrapArray& readTraps() const { return mySystem.m6502().readTraps(); } TrapArray& writeTraps() const { return mySystem.m6502().writeTraps(); } - /*PackedBitArray& readTrapIfs() const { return mySystem.m6502().readTrapIfs(); } - PackedBitArray& writeTrapIfs() const { return mySystem.m6502().writeTrapIfs(); }*/ /** Run the debugger command and return the result. @@ -259,9 +257,6 @@ class Debugger : public DialogContainer void toggleBreakPoint(uInt16 bp); bool breakPoint(uInt16 bp); - /*void toggleReadTrap(uInt16 t); - void toggleWriteTrap(uInt16 t); - void toggleTrap(uInt16 t);*/ void addReadTrap(uInt16 t); void addWriteTrap(uInt16 t); void addTrap(uInt16 t); diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index 3f5f07082..f21f0c9fa 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -586,6 +586,7 @@ bool DebuggerParser::saveScriptFile(string file) if(debugger.breakPoint(i)) out << "break #" << i << endl; + // TODO: new trapif for(uInt32 i = 0; i < 0x10000; ++i) { bool r = debugger.readTrap(i); diff --git a/src/emucore/M6502.cxx b/src/emucore/M6502.cxx index 04a93e40d..7598a60b0 100644 --- a/src/emucore/M6502.cxx +++ b/src/emucore/M6502.cxx @@ -55,6 +55,8 @@ M6502::M6502(const Settings& settings) myLastAddress(0), myLastPeekAddress(0), myLastPokeAddress(0), + myLastPeekBaseAddress(0), + myLastPokeBaseAddress(0), myLastSrcAddressS(-1), myLastSrcAddressA(-1), myLastSrcAddressX(-1), @@ -65,7 +67,7 @@ M6502::M6502(const Settings& settings) { #ifdef DEBUGGER_SUPPORT myDebugger = nullptr; - myJustHitTrapFlag = false; + myJustHitReadTrapFlag = myJustHitWriteTrapFlag = false; #endif } @@ -98,7 +100,7 @@ void M6502::reset() // Load PC from the reset vector PC = uInt16(mySystem->peek(0xfffc)) | (uInt16(mySystem->peek(0xfffd)) << 8); - myLastAddress = myLastPeekAddress = myLastPokeAddress = 0; + myLastAddress = myLastPeekAddress = myLastPokeAddress = myLastPeekBaseAddress = myLastPokeBaseAddress; myLastSrcAddressS = myLastSrcAddressA = myLastSrcAddressX = myLastSrcAddressY = -1; myDataAddressForPoke = 0; @@ -130,9 +132,8 @@ inline uInt8 M6502::peek(uInt16 address, uInt8 flags) int cond = evalCondTraps(); if(cond > -1) { - myJustHitTrapFlag = true; - myHitTrapInfo.message = "RTrap: "; - //myHitTrapInfo.message = "RTrapIf (" + myTrapCondNames[cond] + "): "; + myJustHitReadTrapFlag = true; + myHitTrapInfo.message = "RTrap(" + myTrapCondNames[cond] + "): "; myHitTrapInfo.address = address; } } @@ -163,9 +164,8 @@ inline void M6502::poke(uInt16 address, uInt8 value, uInt8 flags) int cond = evalCondTraps(); if(cond > -1) { - myJustHitTrapFlag = true; - myHitTrapInfo.message = "WTrap: "; - //myHitTrapInfo.message = "WTrapIf (" + myTrapCondNames[cond] + "): "; + myJustHitWriteTrapFlag = true; + myHitTrapInfo.message = "WTrap(" + myTrapCondNames[cond] + "): "; myHitTrapInfo.address = address; } } @@ -200,11 +200,11 @@ bool M6502::execute(uInt32 number) for(; !myExecutionStatus && (number != 0); --number) { #ifdef DEBUGGER_SUPPORT - if(myJustHitTrapFlag) + if(myJustHitReadTrapFlag || myJustHitWriteTrapFlag) { - if(myDebugger && myDebugger->start(myHitTrapInfo.message, myHitTrapInfo.address)) - { - myJustHitTrapFlag = false; + myJustHitReadTrapFlag = myJustHitWriteTrapFlag = false; + if(myDebugger && myDebugger->start(myHitTrapInfo.message, myHitTrapInfo.address, myJustHitReadTrapFlag)) + { return true; } } diff --git a/src/emucore/M6502.hxx b/src/emucore/M6502.hxx index 2c96b1dea..2f5ec5c8f 100644 --- a/src/emucore/M6502.hxx +++ b/src/emucore/M6502.hxx @@ -405,7 +405,8 @@ class M6502 : public Serializable TrapArray myReadTraps, myWriteTraps; // Did we just now hit a trap? - bool myJustHitTrapFlag; + bool myJustHitReadTrapFlag; + bool myJustHitWriteTrapFlag; struct HitTrapInfo { string message; int address;