added 'echo' command to debugger prompt

This commit is contained in:
thrust26 2017-10-02 14:23:08 +02:00
parent 4ecaa9a6e0
commit 43e9693959
3 changed files with 39 additions and 6 deletions

View File

@ -427,6 +427,14 @@ bool DebuggerParser::validateArgs(int cmd)
switch(*p)
{
case kARG_DWORD:
if(curArgInt > 0xffffffff)
{
commandResult.str(red("invalid word argument (must be 0-$ffffffff)"));
return false;
}
break;
case kARG_WORD:
if(curArgInt > 0xffff)
{
@ -925,6 +933,20 @@ void DebuggerParser::executeDump()
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "echo"
void DebuggerParser::executeEcho()
{
int res = YaccParser::parse(argStrings[0].c_str());
if(res == 0)
{
unique_ptr<Expression> expr(YaccParser::getResult());
commandResult << expr->evaluate();
}
else
commandResult << red("invalid expression");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "exec"
void DebuggerParser::executeExec()
@ -1688,7 +1710,6 @@ void DebuggerParser::executeZ()
debugger.cpuDebug().setZ(args[0]);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// List of all commands available to the parser
DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
@ -1907,7 +1928,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{
"dump",
"Dump data at address <xx> [to yy]",
"Examples:\n"
"Example:\n"
" dump f000 - dumps 128 bytes @ f000\n"
" dump f000 f0ff - dumps all bytes from f000 to f0ff",
true,
@ -1916,6 +1937,16 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
std::mem_fn(&DebuggerParser::executeDump)
},
{
"echo",
"Echo expression result",
"Example: echo _fycles, echo _scan*#76, echo _bank==1",
false,
true,
{ kARG_DWORD, kARG_END_ARGS },
std::mem_fn(&DebuggerParser::executeEcho)
},
{
"exec",
"Execute script file <xx>",
@ -1949,7 +1980,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{
"function",
"Define function name xx for expression yy",
"Example: define FUNC1 { ... }",
"Example: function FUNC1 { ... }",
true,
false,
{ kARG_LABEL, kARG_WORD, kARG_END_ARGS },

View File

@ -68,7 +68,7 @@ class DebuggerParser
bool saveScriptFile(string file);
private:
enum { kNumCommands = 72 };
enum { kNumCommands = 73 };
// Constants for argument processing
enum {
@ -80,6 +80,7 @@ class DebuggerParser
enum parameters {
kARG_WORD, // single 16-bit value
kARG_DWORD, // single 32-bit value
kARG_MULTI_WORD, // multiple 16-bit values (must occur last)
kARG_BYTE, // single 8-bit value
kARG_MULTI_BYTE, // multiple 8-bit values (must occur last)
@ -143,6 +144,7 @@ class DebuggerParser
void executeDelwatch();
void executeDisasm();
void executeDump();
void executeEcho();
void executeExec();
void executeExitRom();
void executeFrame();

View File

@ -26,7 +26,7 @@ SaveKey::SaveKey(Jack jack, const Event& event, const System& system,
{
myEEPROM = make_unique<MT24LC256>(eepromfile, system);
myDigitalPinState[One] = myDigitalPinState[Two] = true;
myDigitalPinState[One] = myDigitalPinState[Two] = true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -44,7 +44,7 @@ bool SaveKey::read(DigitalPin pin)
default:
return Controller::read(pin);
}
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -