From ea0561940245628c39fe1ae496abeafcf2f2fa07 Mon Sep 17 00:00:00 2001 From: Thomas Jentzsch Date: Sat, 20 Aug 2022 20:00:03 +0200 Subject: [PATCH] added "swchb" command to debugger --- docs/debugger.html | 1 + src/debugger/DebuggerParser.cxx | 22 ++++++++++++++++++++-- src/debugger/DebuggerParser.hxx | 3 ++- src/debugger/RiotDebug.cxx | 10 ++++++++++ src/debugger/RiotDebug.hxx | 1 + 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/docs/debugger.html b/docs/debugger.html index 90a221cf9..206a7bc2a 100644 --- a/docs/debugger.html +++ b/docs/debugger.html @@ -1017,6 +1017,7 @@ clearSaveStateIfs - Clear all saveState points scanLine - Advance emulation by <xx> scanlines (default=1) step - Single step CPU [with count xx] stepWhile - Single step CPU while <condition> is true + swchb - Set SWCHB to value xx tia - Show TIA state trace - Single step CPU over subroutines [with count xx] trap - Trap read/write access to address(es) xx [yy] diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index 41a2a910d..1982abd1a 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -148,7 +148,9 @@ string DebuggerParser::exec(const FSNode& file, StringList* history) if(!getline(in, command)) break; + ++execDepth; run(command); + --execDepth; if (history != nullptr) history->push_back(command); count++; @@ -1315,9 +1317,7 @@ void DebuggerParser::executeExec() // make sure the commands are added to prompt history StringList history; - ++execDepth; commandResult << exec(node, &history); - --execDepth; for(const auto& item: history) debugger.prompt().addToHistory(item.c_str()); @@ -2159,6 +2159,14 @@ void DebuggerParser::executeStepWhile() commandResult << "executed " << ncycles << " cycles"; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// "swchb" +void DebuggerParser::executeSwchb() +{ + debugger.riotDebug().switches(args[0]); + commandResult << "SWCHB set to " << std::hex << std::setw(2) << std::setfill('0') << args[0]; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // "tia" void DebuggerParser::executeTia() @@ -3381,6 +3389,16 @@ DebuggerParser::CommandArray DebuggerParser::commands = { { std::mem_fn(&DebuggerParser::executeStepWhile) }, + { + "swchb", + "Set SWCHB to xx", + "Example: swchb fe", + true, + true, + { Parameters::ARG_WORD, Parameters::ARG_END_ARGS }, + std::mem_fn(&DebuggerParser::executeSwchb) + }, + { "tia", "Show TIA state", diff --git a/src/debugger/DebuggerParser.hxx b/src/debugger/DebuggerParser.hxx index dbfa4408c..bd8394e4f 100644 --- a/src/debugger/DebuggerParser.hxx +++ b/src/debugger/DebuggerParser.hxx @@ -101,7 +101,7 @@ class DebuggerParser std::array parms; std::function executor; }; - using CommandArray = std::array; + using CommandArray = std::array; static CommandArray commands; struct Trap @@ -234,6 +234,7 @@ class DebuggerParser void executeScanLine(); void executeStep(); void executeStepWhile(); + void executeSwchb(); void executeTia(); void executeTrace(); void executeTrap(); diff --git a/src/debugger/RiotDebug.cxx b/src/debugger/RiotDebug.cxx index c8087d6f8..e3868d75b 100644 --- a/src/debugger/RiotDebug.cxx +++ b/src/debugger/RiotDebug.cxx @@ -257,6 +257,16 @@ int RiotDebug::timReadCycles() const return mySystem.m6532().myTimReadCycles; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool RiotDebug::switches(int newVal) +{ + uInt8& switches = myConsole.switches().mySwitches; + if(newVal > -1) + switches = newVal; + + return switches; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool RiotDebug::diffP0(int newVal) { diff --git a/src/debugger/RiotDebug.hxx b/src/debugger/RiotDebug.hxx index 2aa43bf84..ef90ec4db 100644 --- a/src/debugger/RiotDebug.hxx +++ b/src/debugger/RiotDebug.hxx @@ -89,6 +89,7 @@ class RiotDebug : public DebuggerSystem int intimAsInt() const { return static_cast(intim()); } // so we can use _inTim pseudo-register /* Console switches */ + bool switches(int newVal = -1); bool diffP0(int newVal = -1); bool diffP1(int newVal = -1); bool tvType(int newVal = -1);