Various improvements to the debugger prompt:

- 'cls' now only clears the screen, and not the command history
  - 'help' accepts another command as an argument, to give more info
    about the command (ie, help breakif is now valid)
  - command completion now works on built-in functions and pseudo-ops
This commit is contained in:
Stephen Anthony 2017-04-04 14:17:10 -02:30
parent 467c45e7b2
commit 96bbba223a
5 changed files with 150 additions and 68 deletions

View File

@ -30,8 +30,15 @@
files before starting another instance of the same ROM, when the ROM files before starting another instance of the same ROM, when the ROM
was opened in the ROM launcher. was opened in the ROM launcher.
* Fixed trap'm' debugger commands when setting TIA read addresses; it * Various improvements to the debugger prompt:
was previously only working for write addresses. - The 'cls' command now only clears the screen, not the history
- The 'help' command now accepts other commands, and gives extra
information about the command (ie, 'help breakif' prints extended
information about the breakif command)
- The previous trap'm' commands now work when setting TIA read
addresses; previously they only worked for write addresses
- Command completion now works with internal functions and pseudo-ops
(basically, anything starting with the '_' character)
* Mouse grabbing is now enabled in windowed mode only when the ROM is * Mouse grabbing is now enabled in windowed mode only when the ROM is
using a virtual analog controller (paddles, trakball, etc). using a virtual analog controller (paddles, trakball, etc).

View File

@ -613,12 +613,12 @@ void Debugger::getCompletions(const char* in, StringList& list) const
for(const auto& iter: myFunctions) for(const auto& iter: myFunctions)
{ {
const char* l = iter.first.c_str(); const char* l = iter.first.c_str();
if(BSPF::equalsIgnoreCase(l, in)) if(BSPF::startsWithIgnoreCase(l, in))
list.push_back(l); list.push_back(l);
} }
for(int i = 0; pseudo_registers[i][0] != 0; ++i) for(int i = 0; pseudo_registers[i][0] != 0; ++i)
if(BSPF::equalsIgnoreCase(pseudo_registers[i][0], in)) if(BSPF::startsWithIgnoreCase(pseudo_registers[i][0], in))
list.push_back(pseudo_registers[i][0]); list.push_back(pseudo_registers[i][0]);
} }

View File

@ -986,20 +986,35 @@ void DebuggerParser::executeGfx()
// "help" // "help"
void DebuggerParser::executeHelp() void DebuggerParser::executeHelp()
{ {
// Find length of longest command if(argCount == 0) // normal help, show all commands
uInt16 clen = 0;
for(int i = 0; i < kNumCommands; ++i)
{ {
uInt16 len = commands[i].cmdString.length(); // Find length of longest command
if(len > clen) clen = len; uInt16 clen = 0;
for(int i = 0; i < kNumCommands; ++i)
{
uInt16 len = commands[i].cmdString.length();
if(len > clen) clen = len;
}
commandResult << setfill(' ');
for(int i = 0; i < kNumCommands; ++i)
commandResult << setw(clen) << right << commands[i].cmdString
<< " - " << commands[i].description << endl;
commandResult << debugger.builtinHelp();
}
else // get help for specific command
{
for(int i = 0; i < kNumCommands; ++i)
{
if(argStrings[0] == commands[i].cmdString)
{
commandResult << " " << red(commands[i].description) << endl
<< commands[i].extendedDesc;
break;
}
}
} }
commandResult << setfill(' ');
for(int i = 0; i < kNumCommands; ++i)
commandResult << setw(clen) << right << commands[i].cmdString
<< " - " << commands[i].description << endl;
commandResult << debugger.builtinHelp();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1470,6 +1485,7 @@ void DebuggerParser::executeTrapRW(bool read, bool write)
} }
} }
#if 0
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "trapm" // "trapm"
void DebuggerParser::executeTrapM() void DebuggerParser::executeTrapM()
@ -1575,6 +1591,7 @@ void DebuggerParser::executeTrapMRW(bool read, bool write)
commandResult << trapStatus(addr) << " + mirrors from $" commandResult << trapStatus(addr) << " + mirrors from $"
<< Base::HEX4 << beg << " - $" << end << endl; << Base::HEX4 << beg << " - $" << end << endl;
} }
#endif
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "type" // "type"
@ -1666,7 +1683,8 @@ void DebuggerParser::executeZ()
DebuggerParser::Command DebuggerParser::commands[kNumCommands] = { DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"a", "a",
"Set Accumulator to value xx", "Set Accumulator to <value>",
"Valid value is 0 - 255\nExample: a ff, a #10",
true, true,
true, true,
{ kARG_WORD, kARG_END_ARGS }, { kARG_WORD, kARG_END_ARGS },
@ -1675,7 +1693,8 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"base", "base",
"Set default base (hex, dec, or bin)", "Set default base to <base>",
"Base is hex, dec, or bin\nExample: base hex",
true, true,
true, true,
{ kARG_BASE_SPCL, kARG_END_ARGS }, { kARG_BASE_SPCL, kARG_END_ARGS },
@ -1684,7 +1703,8 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"break", "break",
"Set/clear breakpoint at address xx (default=PC)", "Set/clear breakpoint at <address>",
"Command is a toggle, default is current PC\n:Example: break, break f000",
false, false,
true, true,
{ kARG_WORD, kARG_END_ARGS }, { kARG_WORD, kARG_END_ARGS },
@ -1693,7 +1713,8 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"breakif", "breakif",
"Set breakpoint on condition xx", "Set breakpoint on <condition>",
"Condition can include multiple items, see documentation\nExample: breakif _scan>100",
true, true,
false, false,
{ kARG_WORD, kARG_END_ARGS }, { kARG_WORD, kARG_END_ARGS },
@ -1703,6 +1724,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"c", "c",
"Carry Flag: set (0 or 1), or toggle (no arg)", "Carry Flag: set (0 or 1), or toggle (no arg)",
"Example: c, c 0, c 1",
false, false,
true, true,
{ kARG_BOOL, kARG_END_ARGS }, { kARG_BOOL, kARG_END_ARGS },
@ -1712,6 +1734,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"cheat", "cheat",
"Use a cheat code (see manual for cheat types)", "Use a cheat code (see manual for cheat types)",
"Example: cheat 0040, cheat abff00",
false, false,
false, false,
{ kARG_LABEL, kARG_END_ARGS }, { kARG_LABEL, kARG_END_ARGS },
@ -1721,6 +1744,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"clearbreaks", "clearbreaks",
"Clear all breakpoints", "Clear all breakpoints",
"Example: clearbreaks (no parameters)",
false, false,
true, true,
{ kARG_END_ARGS }, { kARG_END_ARGS },
@ -1730,6 +1754,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"clearconfig", "clearconfig",
"Clear Distella config directives [bank xx]", "Clear Distella config directives [bank xx]",
"Example: clearconfig 0, clearconfig 1",
false, false,
false, false,
{ kARG_WORD, kARG_MULTI_BYTE }, { kARG_WORD, kARG_MULTI_BYTE },
@ -1739,6 +1764,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"cleartraps", "cleartraps",
"Clear all traps", "Clear all traps",
"All traps cleared, including any mirrored ones\nExample: cleartraps (no parameters)",
false, false,
false, false,
{ kARG_END_ARGS }, { kARG_END_ARGS },
@ -1748,6 +1774,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"clearwatches", "clearwatches",
"Clear all watches", "Clear all watches",
"Example: clearwatches (no parameters)",
false, false,
false, false,
{ kARG_END_ARGS }, { kARG_END_ARGS },
@ -1756,7 +1783,8 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"cls", "cls",
"Clear prompt area of text and erase history", "Clear prompt area of text",
"Completely clears screen, but keeps history of commands",
false, false,
false, false,
{ kARG_END_ARGS }, { kARG_END_ARGS },
@ -1766,6 +1794,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"code", "code",
"Mark 'CODE' range in disassembly", "Mark 'CODE' range in disassembly",
"Start and end of range required\nExample: code f000 f010",
true, true,
false, false,
{ kARG_WORD, kARG_MULTI_BYTE }, { kARG_WORD, kARG_MULTI_BYTE },
@ -1775,6 +1804,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"colortest", "colortest",
"Show value xx as TIA color", "Show value xx as TIA color",
"Shows a color swatch for the given value\nExample: colortest 1f",
true, true,
false, false,
{ kARG_WORD, kARG_END_ARGS }, { kARG_WORD, kARG_END_ARGS },
@ -1783,7 +1813,8 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"d", "d",
"Decimal Flag: set (0 or 1), or toggle (no arg)", "Carry Flag: set (0 or 1), or toggle (no arg)",
"Example: d, d 0, d 1",
false, false,
true, true,
{ kARG_BOOL, kARG_END_ARGS }, { kARG_BOOL, kARG_END_ARGS },
@ -1793,6 +1824,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"data", "data",
"Mark 'DATA' range in disassembly", "Mark 'DATA' range in disassembly",
"Start and end of range required\nExample: data f000 f010",
true, true,
false, false,
{ kARG_WORD, kARG_MULTI_BYTE }, { kARG_WORD, kARG_MULTI_BYTE },
@ -1802,6 +1834,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"define", "define",
"Define label xx for address yy", "Define label xx for address yy",
"Example: define LABEL1 f100",
true, true,
true, true,
{ kARG_LABEL, kARG_WORD, kARG_END_ARGS }, { kARG_LABEL, kARG_WORD, kARG_END_ARGS },
@ -1810,7 +1843,8 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"delbreakif", "delbreakif",
"Delete conditional breakif xx", "Delete conditional breakif <xx>",
"Example: delbreakif 0",
true, true,
false, false,
{ kARG_WORD, kARG_END_ARGS }, { kARG_WORD, kARG_END_ARGS },
@ -1820,6 +1854,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"delfunction", "delfunction",
"Delete function with label xx", "Delete function with label xx",
"Example: delfunction FUNC1",
true, true,
false, false,
{ kARG_LABEL, kARG_END_ARGS }, { kARG_LABEL, kARG_END_ARGS },
@ -1828,7 +1863,8 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"delwatch", "delwatch",
"Delete watch xx", "Delete watch <xx>",
"Example: delwatch 0",
true, true,
false, false,
{ kARG_WORD, kARG_END_ARGS }, { kARG_WORD, kARG_END_ARGS },
@ -1838,6 +1874,8 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"disasm", "disasm",
"Disassemble address xx [yy lines] (default=PC)", "Disassemble address xx [yy lines] (default=PC)",
"Disassembles from starting address <xx> (default=PC) for <yy> lines\n"
"Example: disasm, disasm f000 100",
false, false,
false, false,
{ kARG_WORD, kARG_MULTI_BYTE }, { kARG_WORD, kARG_MULTI_BYTE },
@ -1846,7 +1884,8 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"dump", "dump",
"Dump 128 bytes of memory at address xx", "Dump 128 bytes of memory at address <xx>",
"Example: dump f000",
true, true,
false, false,
{ kARG_WORD, kARG_END_ARGS }, { kARG_WORD, kARG_END_ARGS },
@ -1855,7 +1894,8 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"exec", "exec",
"Execute script file xx", "Execute script file <xx>",
"Example: exec script.dat, exec auto.txt",
true, true,
true, true,
{ kARG_FILE, kARG_END_ARGS }, { kARG_FILE, kARG_END_ARGS },
@ -1865,6 +1905,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"exitrom", "exitrom",
"Exit emulator, return to ROM launcher", "Exit emulator, return to ROM launcher",
"Self-explanatory",
false, false,
false, false,
{ kARG_END_ARGS }, { kARG_END_ARGS },
@ -1873,7 +1914,8 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"frame", "frame",
"Advance emulation by xx frames (default=1)", "Advance emulation by <xx> frames (default=1)",
"Example: frame, frame 100",
false, false,
true, true,
{ kARG_WORD, kARG_END_ARGS }, { kARG_WORD, kARG_END_ARGS },
@ -1883,6 +1925,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 { ... }",
true, true,
false, false,
{ kARG_LABEL, kARG_WORD, kARG_END_ARGS }, { kARG_LABEL, kARG_WORD, kARG_END_ARGS },
@ -1891,7 +1934,8 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"gfx", "gfx",
"Mark 'CFX' range in disassembly", "Mark 'GFX' range in disassembly",
"Start and end of range required\nExample: gfx f000 f010",
true, true,
false, false,
{ kARG_WORD, kARG_MULTI_BYTE }, { kARG_WORD, kARG_MULTI_BYTE },
@ -1900,16 +1944,19 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"help", "help",
"This cruft", "help <command>",
"Show all commands, or give function for help on that command\n"
"Example: help, help code",
false, false,
false, false,
{ kARG_END_ARGS }, { kARG_LABEL, kARG_END_ARGS },
std::mem_fn(&DebuggerParser::executeHelp) std::mem_fn(&DebuggerParser::executeHelp)
}, },
{ {
"jump", "jump",
"Scroll disassembly to address xx", "Scroll disassembly to address xx",
"Moves disassembly listing to address <xx>\nExample: jump f400",
true, true,
false, false,
{ kARG_WORD, kARG_END_ARGS }, { kARG_WORD, kARG_END_ARGS },
@ -1919,6 +1966,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"listbreaks", "listbreaks",
"List breakpoints", "List breakpoints",
"Example: listbreaks (no parameters)",
false, false,
false, false,
{ kARG_END_ARGS }, { kARG_END_ARGS },
@ -1928,6 +1976,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"listconfig", "listconfig",
"List Distella config directives [bank xx]", "List Distella config directives [bank xx]",
"Example: listconfig 0, listconfig 1",
false, false,
false, false,
{ kARG_WORD, kARG_MULTI_BYTE }, { kARG_WORD, kARG_MULTI_BYTE },
@ -1937,6 +1986,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"listfunctions", "listfunctions",
"List user-defined functions", "List user-defined functions",
"Example: listfunctions (no parameters)",
false, false,
false, false,
{ kARG_END_ARGS }, { kARG_END_ARGS },
@ -1946,6 +1996,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"listtraps", "listtraps",
"List traps", "List traps",
"Lists all traps (read and/or write)\nExample: listtraps (no parameters)",
false, false,
false, false,
{ kARG_END_ARGS }, { kARG_END_ARGS },
@ -1955,6 +2006,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"loadconfig", "loadconfig",
"Load Distella config file", "Load Distella config file",
"Example: loadconfig file.cfg",
false, false,
true, true,
{ kARG_END_ARGS }, { kARG_END_ARGS },
@ -1964,6 +2016,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"loadstate", "loadstate",
"Load emulator state xx (0-9)", "Load emulator state xx (0-9)",
"Example: loadstate 0, loadstate 9",
true, true,
true, true,
{ kARG_WORD, kARG_END_ARGS }, { kARG_WORD, kARG_END_ARGS },
@ -1973,6 +2026,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"n", "n",
"Negative Flag: set (0 or 1), or toggle (no arg)", "Negative Flag: set (0 or 1), or toggle (no arg)",
"Example: n, n 0, n 1",
false, false,
true, true,
{ kARG_BOOL, kARG_END_ARGS }, { kARG_BOOL, kARG_END_ARGS },
@ -1982,6 +2036,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"pc", "pc",
"Set Program Counter to address xx", "Set Program Counter to address xx",
"Example: pc f000",
true, true,
true, true,
{ kARG_WORD, kARG_END_ARGS }, { kARG_WORD, kARG_END_ARGS },
@ -1991,6 +2046,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"pgfx", "pgfx",
"Mark 'PGFX' range in disassembly", "Mark 'PGFX' range in disassembly",
"Start and end of range required\nExample: pgfx f000 f010",
true, true,
false, false,
{ kARG_WORD, kARG_MULTI_BYTE }, { kARG_WORD, kARG_MULTI_BYTE },
@ -2000,6 +2056,8 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"print", "print",
"Evaluate/print expression xx in hex/dec/binary", "Evaluate/print expression xx in hex/dec/binary",
"Almost anything can be printed (constants, expressions, registers)\n"
"Example: print pc, print f000",
true, true,
false, false,
{ kARG_WORD, kARG_END_ARGS }, { kARG_WORD, kARG_END_ARGS },
@ -2009,6 +2067,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"ram", "ram",
"Show ZP RAM, or set address xx to yy1 [yy2 ...]", "Show ZP RAM, or set address xx to yy1 [yy2 ...]",
"Example: ram, ram 80 00 ...",
false, false,
true, true,
{ kARG_WORD, kARG_MULTI_BYTE }, { kARG_WORD, kARG_MULTI_BYTE },
@ -2018,6 +2077,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"reset", "reset",
"Reset system to power-on state", "Reset system to power-on state",
"System is completely reset, just as if it was just powered on",
false, false,
true, true,
{ kARG_END_ARGS }, { kARG_END_ARGS },
@ -2027,6 +2087,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"rewind", "rewind",
"Rewind state to last step/trace/scanline/frame", "Rewind state to last step/trace/scanline/frame",
"Rewind currently only works in the debugger",
false, false,
true, true,
{ kARG_END_ARGS }, { kARG_END_ARGS },
@ -2036,6 +2097,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"riot", "riot",
"Show RIOT timer/input status", "Show RIOT timer/input status",
"Display text-based output of the contents of the RIOT tab",
false, false,
false, false,
{ kARG_END_ARGS }, { kARG_END_ARGS },
@ -2045,6 +2107,8 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"rom", "rom",
"Set ROM address xx to yy1 [yy2 ...]", "Set ROM address xx to yy1 [yy2 ...]",
"What happens here depends on the current bankswitching scheme\n"
"Example: rom f000 00 01 ff ...",
true, true,
true, true,
{ kARG_WORD, kARG_MULTI_BYTE }, { kARG_WORD, kARG_MULTI_BYTE },
@ -2054,6 +2118,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"row", "row",
"Mark 'ROW' range in disassembly", "Mark 'ROW' range in disassembly",
"Start and end of range required\nExample: row f000 f010",
true, true,
false, false,
{ kARG_WORD, kARG_MULTI_BYTE }, { kARG_WORD, kARG_MULTI_BYTE },
@ -2063,6 +2128,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"run", "run",
"Exit debugger, return to emulator", "Exit debugger, return to emulator",
"Self-explanatory",
false, false,
false, false,
{ kARG_END_ARGS }, { kARG_END_ARGS },
@ -2072,6 +2138,8 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"runto", "runto",
"Run until string xx in disassembly", "Run until string xx in disassembly",
"Advance until the given string is detected in the disassembly\n"
"Example: runto lda",
true, true,
true, true,
{ kARG_LABEL, kARG_END_ARGS }, { kARG_LABEL, kARG_END_ARGS },
@ -2081,6 +2149,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"runtopc", "runtopc",
"Run until PC is set to value xx", "Run until PC is set to value xx",
"Example: runtopc f200",
true, true,
true, true,
{ kARG_WORD, kARG_END_ARGS }, { kARG_WORD, kARG_END_ARGS },
@ -2090,6 +2159,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"s", "s",
"Set Stack Pointer to value xx", "Set Stack Pointer to value xx",
"Example: s f0",
true, true,
true, true,
{ kARG_WORD, kARG_END_ARGS }, { kARG_WORD, kARG_END_ARGS },
@ -2099,6 +2169,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"save", "save",
"Save breaks, watches, traps to file xx", "Save breaks, watches, traps to file xx",
"Example: save commands.txt",
true, true,
false, false,
{ kARG_FILE, kARG_END_ARGS }, { kARG_FILE, kARG_END_ARGS },
@ -2108,6 +2179,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"saveconfig", "saveconfig",
"Save Distella config file", "Save Distella config file",
"Example: saveconfig file.cfg",
false, false,
false, false,
{ kARG_END_ARGS }, { kARG_END_ARGS },
@ -2117,6 +2189,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"savedis", "savedis",
"Save Distella disassembly", "Save Distella disassembly",
"Example: savedis file.asm",
false, false,
false, false,
{ kARG_END_ARGS }, { kARG_END_ARGS },
@ -2126,6 +2199,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"saverom", "saverom",
"Save (possibly patched) ROM", "Save (possibly patched) ROM",
"Example: savedrom file.bin",
false, false,
false, false,
{ kARG_END_ARGS }, { kARG_END_ARGS },
@ -2135,6 +2209,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"saveses", "saveses",
"Save console session to file xx", "Save console session to file xx",
"Example: saveses session.txt",
true, true,
false, false,
{ kARG_FILE, kARG_END_ARGS }, { kARG_FILE, kARG_END_ARGS },
@ -2144,6 +2219,8 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"savesnap", "savesnap",
"Save current TIA image to PNG file", "Save current TIA image to PNG file",
"Save snapshot to current snapshot save directory\n"
"Example: savesnap (no parameters)",
false, false,
false, false,
{ kARG_END_ARGS }, { kARG_END_ARGS },
@ -2153,6 +2230,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"savestate", "savestate",
"Save emulator state xx (valid args 0-9)", "Save emulator state xx (valid args 0-9)",
"Example: savestate 0, savestate 9",
true, true,
false, false,
{ kARG_WORD, kARG_END_ARGS }, { kARG_WORD, kARG_END_ARGS },
@ -2161,7 +2239,8 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"scanline", "scanline",
"Advance emulation by xx scanlines (default=1)", "Advance emulation by <xx> scanlines (default=1)",
"Example: scanline, scanline 100",
false, false,
true, true,
{ kARG_WORD, kARG_END_ARGS }, { kARG_WORD, kARG_END_ARGS },
@ -2171,6 +2250,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"step", "step",
"Single step CPU [with count xx]", "Single step CPU [with count xx]",
"Example: step, step 100",
false, false,
true, true,
{ kARG_WORD, kARG_END_ARGS }, { kARG_WORD, kARG_END_ARGS },
@ -2179,7 +2259,8 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"tia", "tia",
"Show TIA state (NOT FINISHED YET)", "Show TIA state",
"Display text-based output of the contents of the TIA tab",
false, false,
false, false,
{ kARG_END_ARGS }, { kARG_END_ARGS },
@ -2189,6 +2270,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"trace", "trace",
"Single step CPU over subroutines [with count xx]", "Single step CPU over subroutines [with count xx]",
"Example: trace, trace 100",
false, false,
true, true,
{ kARG_WORD, kARG_END_ARGS }, { kARG_WORD, kARG_END_ARGS },
@ -2198,6 +2280,8 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"trap", "trap",
"Trap read/write access to address(es) xx [to yy]", "Trap read/write access to address(es) xx [to yy]",
"Set a R/W trap on the given address(es) and all mirrors\n"
"Example: trap f000, trap f000 f100",
true, true,
false, false,
{ kARG_WORD, kARG_MULTI_BYTE }, { kARG_WORD, kARG_MULTI_BYTE },
@ -2207,6 +2291,8 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"trapread", "trapread",
"Trap read access to address(es) xx [to yy]", "Trap read access to address(es) xx [to yy]",
"Set a read trap on the given address(es) and all mirrors\n"
"Example: trapread f000, trapread f000 f100",
true, true,
false, false,
{ kARG_WORD, kARG_MULTI_BYTE }, { kARG_WORD, kARG_MULTI_BYTE },
@ -2216,42 +2302,18 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"trapwrite", "trapwrite",
"Trap write access to address(es) xx [to yy]", "Trap write access to address(es) xx [to yy]",
"Set a write trap on the given address(es) and all mirrors\n"
"Example: trapwrite f000, trapwrite f000 f100",
true, true,
false, false,
{ kARG_WORD, kARG_MULTI_BYTE }, { kARG_WORD, kARG_MULTI_BYTE },
std::mem_fn(&DebuggerParser::executeTrapwrite) std::mem_fn(&DebuggerParser::executeTrapwrite)
}, },
{
"trapm",
"Trap read/write access to address xx (+mirrors)",
true,
false,
{ kARG_WORD, kARG_MULTI_WORD },
std::mem_fn(&DebuggerParser::executeTrapM)
},
{
"trapreadm",
"Trap read access to address xx (+mirrors)",
true,
false,
{ kARG_WORD, kARG_MULTI_WORD },
std::mem_fn(&DebuggerParser::executeTrapreadM)
},
{
"trapwritem",
"Trap write access to address xx (+mirrors)",
true,
false,
{ kARG_WORD, kARG_MULTI_WORD },
std::mem_fn(&DebuggerParser::executeTrapwriteM)
},
{ {
"type", "type",
"Show disassembly type for address xx [to yy]", "Show disassembly type for address xx [to yy]",
"Example: type f000, type f000 f010",
true, true,
false, false,
{ kARG_WORD, kARG_MULTI_BYTE }, { kARG_WORD, kARG_MULTI_BYTE },
@ -2261,6 +2323,8 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"uhex", "uhex",
"Toggle upper/lowercase HEX display", "Toggle upper/lowercase HEX display",
"Note: not all hex output can be changed\n"
"Example: uhex (no parameters)",
false, false,
true, true,
{ kARG_END_ARGS }, { kARG_END_ARGS },
@ -2270,6 +2334,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"undef", "undef",
"Undefine label xx (if defined)", "Undefine label xx (if defined)",
"Example: undef LABEL1",
true, true,
true, true,
{ kARG_LABEL, kARG_END_ARGS }, { kARG_LABEL, kARG_END_ARGS },
@ -2279,6 +2344,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"v", "v",
"Overflow Flag: set (0 or 1), or toggle (no arg)", "Overflow Flag: set (0 or 1), or toggle (no arg)",
"Example: v, v 0, v 1",
false, false,
true, true,
{ kARG_BOOL, kARG_END_ARGS }, { kARG_BOOL, kARG_END_ARGS },
@ -2288,6 +2354,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"watch", "watch",
"Print contents of address xx before every prompt", "Print contents of address xx before every prompt",
"Example: watch ram_80",
true, true,
false, false,
{ kARG_WORD, kARG_END_ARGS }, { kARG_WORD, kARG_END_ARGS },
@ -2297,6 +2364,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"x", "x",
"Set X Register to value xx", "Set X Register to value xx",
"Valid value is 0 - 255\nExample: x ff, x #10",
true, true,
true, true,
{ kARG_WORD, kARG_END_ARGS }, { kARG_WORD, kARG_END_ARGS },
@ -2306,6 +2374,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"y", "y",
"Set Y Register to value xx", "Set Y Register to value xx",
"Valid value is 0 - 255\nExample: y ff, y #10",
true, true,
true, true,
{ kARG_WORD, kARG_END_ARGS }, { kARG_WORD, kARG_END_ARGS },
@ -2315,6 +2384,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"z", "z",
"Zero Flag: set (0 or 1), or toggle (no arg)", "Zero Flag: set (0 or 1), or toggle (no arg)",
"Example: z, z 0, z 1",
false, false,
true, true,
{ kARG_BOOL, kARG_END_ARGS }, { kARG_BOOL, kARG_END_ARGS },

View File

@ -68,7 +68,7 @@ class DebuggerParser
bool saveScriptFile(string file); bool saveScriptFile(string file);
private: private:
enum { kNumCommands = 73 }; enum { kNumCommands = 70 };
// Constants for argument processing // Constants for argument processing
enum { enum {
@ -93,6 +93,7 @@ class DebuggerParser
struct Command { struct Command {
string cmdString; string cmdString;
string description; string description;
string extendedDesc;
bool parmsRequired; bool parmsRequired;
bool refreshRequired; bool refreshRequired;
parameters parms[10]; parameters parms[10];
@ -179,10 +180,6 @@ class DebuggerParser
void executeTrapread(); void executeTrapread();
void executeTrapwrite(); void executeTrapwrite();
void executeTrapRW(bool read, bool write); // not exposed by debugger void executeTrapRW(bool read, bool write); // not exposed by debugger
void executeTrapM();
void executeTrapreadM();
void executeTrapwriteM();
void executeTrapMRW(bool read, bool write); // not exposed by debugger
void executeType(); void executeType();
void executeUHex(); void executeUHex();
void executeUndef(); void executeUndef();

View File

@ -240,11 +240,19 @@ bool PromptWidget::handleKeyDown(StellaKey key, StellaMod mod)
} }
else else
{ {
// we got a delimiter, so this must be a label or a function // Special case for 'help' command
const Debugger& dbg = instance().debugger(); if(BSPF::startsWithIgnoreCase(str, "help"))
{
instance().debugger().parser().getCompletions(str + lastDelimPos + 1, list);
}
else
{
// we got a delimiter, so this must be a label or a function
const Debugger& dbg = instance().debugger();
dbg.cartDebug().getCompletions(str + lastDelimPos + 1, list); dbg.cartDebug().getCompletions(str + lastDelimPos + 1, list);
dbg.getCompletions(str + lastDelimPos + 1, list); dbg.getCompletions(str + lastDelimPos + 1, list);
}
if(list.size() < 1) if(list.size() < 1)
break; break;