From: <ste...@us...> - 2016-09-04 23:03:03
|
Revision: 3317 http://sourceforge.net/p/stella/code/3317 Author: stephena Date: 2016-09-04 23:03:01 +0000 (Sun, 04 Sep 2016) Log Message: ----------- Added versions of the debugger trap commands that trap on all mirrors, not just the specified address. Modified Paths: -------------- trunk/Changes.txt trunk/Makefile trunk/src/debugger/CartDebug.hxx trunk/src/debugger/DebuggerParser.cxx trunk/src/debugger/DebuggerParser.hxx Modified: trunk/Changes.txt =================================================================== --- trunk/Changes.txt 2016-08-24 23:57:07 UTC (rev 3316) +++ trunk/Changes.txt 2016-09-04 23:03:01 UTC (rev 3317) @@ -21,6 +21,10 @@ Thanks to Omegamatrix of AtariAge for the bug report and patch to fix the issue. + * Added 'trapm', 'trapreadm', 'trapwritem' commands to debugger prompt. + These are similar to the non-'m' versions, except that they also trap + on all mirrors of the given address. + * Fixed bug in debugger 'reset' command; it wasn't resetting the bankswitching, so after a reset the banks were in an undefined state. Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2016-08-24 23:57:07 UTC (rev 3316) +++ trunk/Makefile 2016-09-04 23:03:01 UTC (rev 3317) @@ -26,7 +26,7 @@ srcdir ?= . -DEFINES := +DEFINES := -D_GLIBCXX_USE_CXX11_ABI=1 LDFLAGS := INCLUDES := LIBS := Modified: trunk/src/debugger/CartDebug.hxx =================================================================== --- trunk/src/debugger/CartDebug.hxx 2016-08-24 23:57:07 UTC (rev 3316) +++ trunk/src/debugger/CartDebug.hxx 2016-09-04 23:03:01 UTC (rev 3317) @@ -87,6 +87,15 @@ int fieldwidth; }; + // Determine 'type' of address (ie, what part of the system accessed) + enum AddrType { + ADDR_TIA, + ADDR_IO, + ADDR_ZPRAM, + ADDR_ROM + }; + AddrType addressType(uInt16 addr) const; + public: CartDebug(Debugger& dbg, Console& console, const OSystem& osystem); virtual ~CartDebug() = default; @@ -266,15 +275,6 @@ using AddrToLabel = std::map<uInt16, string>; using LabelToAddr = std::map<string, uInt16>; - // Determine 'type' of address (ie, what part of the system accessed) - enum AddrType { - ADDR_TIA, - ADDR_IO, - ADDR_ZPRAM, - ADDR_ROM - }; - AddrType addressType(uInt16 addr) const; - struct DirectiveTag { DisasmType type; uInt16 start; Modified: trunk/src/debugger/DebuggerParser.cxx =================================================================== --- trunk/src/debugger/DebuggerParser.cxx 2016-08-24 23:57:07 UTC (rev 3316) +++ trunk/src/debugger/DebuggerParser.cxx 2016-09-04 23:03:01 UTC (rev 3317) @@ -567,9 +567,9 @@ else if(r) result += "read"; else if(w) - result += " write"; + result += "write"; else - result += " none "; + result += "none"; // TODO - technically, we should determine if the label is read or write const string& l = debugger.cartDebug().getLabel(addr, true); @@ -585,9 +585,8 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool DebuggerParser::saveScriptFile(string file) { - if( file.find_last_of('.') == string::npos ) { + if( file.find_last_of('.') == string::npos ) file += ".stella"; - } ofstream out(file); @@ -1440,46 +1439,141 @@ // "trap" void DebuggerParser::executeTrap() { - uInt32 beg = args[0]; - uInt32 end = argCount >= 2 ? args[1] : beg; - if(beg > end) std::swap(beg, end); - - for(uInt32 i = beg; i <= end; ++i) - { - debugger.toggleReadTrap(i); - debugger.toggleWriteTrap(i); - commandResult << trapStatus(i) << endl; - } + executeTrapRW(true, true); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // "trapread" void DebuggerParser::executeTrapread() { + executeTrapRW(true, false); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// "trapwrite" +void DebuggerParser::executeTrapwrite() +{ + executeTrapRW(false, true); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// wrapper function for trap/trapread/trapwrite commands +void DebuggerParser::executeTrapRW(bool read, bool write) +{ uInt32 beg = args[0]; uInt32 end = argCount >= 2 ? args[1] : beg; if(beg > end) std::swap(beg, end); for(uInt32 i = beg; i <= end; ++i) { - debugger.toggleReadTrap(i); + if(read) debugger.toggleReadTrap(i); + if(write) debugger.toggleWriteTrap(i); commandResult << trapStatus(i) << endl; } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// "trapwrite" -void DebuggerParser::executeTrapwrite() +// "trapm" +void DebuggerParser::executeTrapM() { - uInt32 beg = args[0]; - uInt32 end = argCount >= 2 ? args[1] : beg; + executeTrapMRW(true, true); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// "trapreadm" +void DebuggerParser::executeTrapreadM() +{ + executeTrapMRW(true, false); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// "trapwritem" +void DebuggerParser::executeTrapwriteM() +{ + executeTrapMRW(false, true); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// wrapper function for trapm/trapreadm/trapwritem commands +void DebuggerParser::executeTrapMRW(bool read, bool write) +{ + uInt32 addr = args[0]; + uInt32 beg = argCount > 1 ? args[1] : 0; + uInt32 end = argCount > 2 ? args[2] : 0xFFFF; if(beg > end) std::swap(beg, end); - for(uInt32 i = beg; i <= end; ++i) + switch(debugger.cartDebug().addressType(addr)) { - debugger.toggleWriteTrap(i); - commandResult << trapStatus(i) << endl; + case CartDebug::ADDR_TIA: + { + for(uInt32 i = beg; i <= end; ++i) + { + if((i & 0x1080) == 0x0000 && (i & 0x003F) == addr) + { + if(read) debugger.toggleReadTrap(i); + if(write) debugger.toggleWriteTrap(i); + } + } + break; + } + case CartDebug::ADDR_IO: + { + for(uInt32 i = beg; i <= end; ++i) + { + if((i & 0x1080) == 0x0080 && (i & 0x0200) != 0x0000 && (i & 0x02FF) == addr) + { + if(read) debugger.toggleReadTrap(i); + if(write) debugger.toggleWriteTrap(i); + } + } + break; + } + case CartDebug::ADDR_ZPRAM: + { + for(uInt32 i = beg; i <= end; ++i) + { + if((i & 0x1080) == 0x0080 && (i & 0x0200) == 0x0000 && (i & 0x00FF) == addr) + { + if(read) debugger.toggleReadTrap(i); + if(write) debugger.toggleWriteTrap(i); + } + } + break; + } + case CartDebug::ADDR_ROM: + { + // Enforce range? + if(argCount > 1) + { + if(beg < addr) beg = addr & 0xF000; + if(end < beg) beg = end; + } + else + { + beg = 0x1000; + end = 0xFFFF; + } + + // Are we in range? + if(!(addr >= beg && addr <= end)) + { + commandResult << "Address " << addr << " is outside range" << endl; + return; + } + for(uInt32 i = beg; i <= end; ++i) + { + if((i % 0x2000 >= 0x1000) && (i & 0x0FFF) == (addr & 0x0FFF)) + { + if(read) debugger.toggleReadTrap(i); + if(write) debugger.toggleWriteTrap(i); + } + } + break; + } } + + commandResult << trapStatus(addr) << " + mirrors from $" + << Base::HEX4 << beg << " - $" << end << endl; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2129,6 +2223,33 @@ }, { + "trapm", + "Trap read/write access to address xx (+mirrors)", + true, + false, + { kARG_WORD, kARG_MULTI_WORD }, + std::mem_fn(&DebuggerParser::executeTrapM) + }, + + { + "trapreadm", + "Trap read access to address xx (+mirrors)", + true, + false, + { kARG_WORD, kARG_MULTI_WORD }, + std::mem_fn(&DebuggerParser::executeTrapreadM) + }, + + { + "trapwritem", + "Trap write access to address xx (+mirrors)", + true, + false, + { kARG_WORD, kARG_MULTI_WORD }, + std::mem_fn(&DebuggerParser::executeTrapwriteM) + }, + + { "type", "Show disassembly type for address xx [to yy]", true, Modified: trunk/src/debugger/DebuggerParser.hxx =================================================================== --- trunk/src/debugger/DebuggerParser.hxx 2016-08-24 23:57:07 UTC (rev 3316) +++ trunk/src/debugger/DebuggerParser.hxx 2016-09-04 23:03:01 UTC (rev 3317) @@ -70,9 +70,7 @@ bool saveScriptFile(string file); private: - enum { - kNumCommands = 70 - }; + enum { kNumCommands = 73 }; // Constants for argument processing enum { @@ -182,6 +180,11 @@ void executeTrap(); void executeTrapread(); void executeTrapwrite(); + void executeTrapRW(bool read, bool write); // not exposed by debugger + void executeTrapM(); + void executeTrapreadM(); + void executeTrapwriteM(); + void executeTrapMRW(bool read, bool write); // not exposed by debugger void executeType(); void executeUHex(); void executeUndef(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |