Add new debugger command 'stepwhile'.

This command steps through the code instruction-by-instruction (just like the
'step' command) while the <condition> argument evaluates to true. This is a
(pretty slow) workaround for breakpoints and the 'run' command which seems
broken from debugging scripts.
This commit is contained in:
Markus Uhr 2017-11-13 22:27:38 +01:00 committed by Stephen Anthony
parent e6b5d792b7
commit 7010400235
2 changed files with 29 additions and 1 deletions

View File

@ -1766,6 +1766,23 @@ void DebuggerParser::executeStep()
<< "executed " << dec << debugger.step() << " cycles";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "stepwhile"
void DebuggerParser::executeStepwhile()
{
int res = YaccParser::parse(argStrings[0].c_str());
if(res != 0) {
commandResult << red("invalid expression");
return;
}
Expression* expr = YaccParser::getResult();
int ncycles = 0;
do {
ncycles += debugger.step();
} while (expr->evaluate());
commandResult << "executed " << ncycles << " cycles";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "tia"
void DebuggerParser::executeTia()
@ -2868,6 +2885,16 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
std::mem_fn(&DebuggerParser::executeStep)
},
{
"stepwhile",
"Single step CPU while <condition> is true",
"Example: stepwhile pc!=$f2a9",
true,
true,
{ kARG_WORD, kARG_END_ARGS },
std::mem_fn(&DebuggerParser::executeStepwhile)
},
{
"tia",
"Show TIA state",

View File

@ -66,7 +66,7 @@ class DebuggerParser
string saveScriptFile(string file);
private:
enum { kNumCommands = 91 };
enum { kNumCommands = 92 };
// Constants for argument processing
enum {
@ -210,6 +210,7 @@ class DebuggerParser
void executeSavestateif();
void executeScanline();
void executeStep();
void executeStepwhile();
void executeTia();
void executeTrace();
void executeTrap();