Extend debugger 'dump' command to take second parameter (for end of data range).

This commit is contained in:
Stephen Anthony 2017-09-08 22:23:45 -02:30
parent 823c693a9e
commit a018dc604a
3 changed files with 37 additions and 11 deletions

View File

@ -27,6 +27,9 @@
* Added debugger pseudo-register '_fcycles', which gives the number of
CPU cycles that have occurred since the frame started.
* Extended debugger 'dump' command to take a second argument, indicating
the end of the range to dump data.
* Improved emulation of 'FE' bankswitch scheme (no user-visible changes,
but internally the emulation is much more accurate compared to the
real thing). Related to this, improved the debugger support for this

View File

@ -647,7 +647,7 @@ Type "help 'cmd'" to see extended information about the given command.</p>
delfunction - Delete function with label xx
delwatch - Delete watch &lt;xx&gt;
disasm - Disassemble address xx [yy lines] (default=PC)
dump - Dump 128 bytes of memory at address &lt;xx&gt;
dump - Dump data at address &lt;xx&gt; [to yy]
exec - Execute script file &lt;xx&gt;
exitrom - Exit emulator, return to ROM launcher
frame - Advance emulation by &lt;xx&gt; frames (default=1)

View File

@ -891,16 +891,37 @@ void DebuggerParser::executeDisasm()
// "dump"
void DebuggerParser::executeDump()
{
for(int i = 0; i < 8; ++i)
auto dump = [&](int start, int end)
{
int start = args[0] + i*16;
commandResult << Base::toString(start) << ": ";
for(int j = 0; j < 16; ++j)
for(int i = start; i <= end; i += 16)
{
commandResult << Base::toString(debugger.peek(start+j)) << " ";
if(j == 7) commandResult << "- ";
// Print label every 16 bytes
commandResult << Base::toString(i) << ": ";
for(int j = i; j < i+16 && j <= end; ++j)
{
commandResult << Base::toString(debugger.peek(j)) << " ";
if(j == i+7 && j != end) commandResult << "- ";
}
if(i != 7) commandResult << endl;
commandResult << endl;
}
};
// Error checking
if(argCount > 1 && args[1] < args[0])
{
commandResult << red("Start address must be <= end address");
return;
}
if(argCount == 1)
dump(args[0], args[0] + 127);
else if(argCount == 2)
dump(args[0], args[1]);
else
{
commandResult << "wrong number of arguments";
return;
}
}
@ -1875,11 +1896,13 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{
"dump",
"Dump 128 bytes of memory at address <xx>",
"Example: dump f000",
"Dump data at address <xx> [to yy]",
"Examples:\n"
" dump f000 - dumps 128 bytes @ f000\n"
" dump f000 f0ff - dumps all bytes from f000 to f0ff",
true,
false,
{ kARG_WORD, kARG_END_ARGS },
{ kARG_WORD, kARG_MULTI_BYTE },
std::mem_fn(&DebuggerParser::executeDump)
},