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) switch(*p)
{ {
case kARG_DWORD:
if(curArgInt > 0xffffffff)
{
commandResult.str(red("invalid word argument (must be 0-$ffffffff)"));
return false;
}
break;
case kARG_WORD: case kARG_WORD:
if(curArgInt > 0xffff) 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" // "exec"
void DebuggerParser::executeExec() void DebuggerParser::executeExec()
@ -1688,7 +1710,6 @@ void DebuggerParser::executeZ()
debugger.cpuDebug().setZ(args[0]); debugger.cpuDebug().setZ(args[0]);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// List of all commands available to the parser // List of all commands available to the parser
DebuggerParser::Command DebuggerParser::commands[kNumCommands] = { DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
@ -1907,7 +1928,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"dump", "dump",
"Dump data at address <xx> [to yy]", "Dump data at address <xx> [to yy]",
"Examples:\n" "Example:\n"
" dump f000 - dumps 128 bytes @ f000\n" " dump f000 - dumps 128 bytes @ f000\n"
" dump f000 f0ff - dumps all bytes from f000 to f0ff", " dump f000 f0ff - dumps all bytes from f000 to f0ff",
true, true,
@ -1916,6 +1937,16 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
std::mem_fn(&DebuggerParser::executeDump) 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", "exec",
"Execute script file <xx>", "Execute script file <xx>",
@ -1949,7 +1980,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"function", "function",
"Define function name xx for expression yy", "Define function name xx for expression yy",
"Example: define FUNC1 { ... }", "Example: function FUNC1 { ... }",
true, true,
false, false,
{ kARG_LABEL, kARG_WORD, kARG_END_ARGS }, { kARG_LABEL, kARG_WORD, kARG_END_ARGS },

View File

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