Debugger: platformCommands should be able to be NULL

This commit is contained in:
Vicki Pfau 2022-10-03 15:54:51 -07:00
parent 9adad40b1c
commit 168c9cb8d6
2 changed files with 19 additions and 13 deletions

View File

@ -326,16 +326,24 @@ static void _printHelp(struct CLIDebugger* debugger, struct CLIDebugVector* dv)
debugger->backend->printf(debugger->backend, "Generic commands:\n");
_printCommands(debugger, _debuggerCommands, _debuggerCommandAliases);
if (debugger->system) {
debugger->backend->printf(debugger->backend, "\n%s commands:\n", debugger->system->platformName);
_printCommands(debugger, debugger->system->platformCommands, debugger->system->platformCommandAliases);
debugger->backend->printf(debugger->backend, "\n%s commands:\n", debugger->system->name);
_printCommands(debugger, debugger->system->commands, debugger->system->commandAliases);
if (debugger->system->platformCommands) {
debugger->backend->printf(debugger->backend, "\n%s commands:\n", debugger->system->platformName);
_printCommands(debugger, debugger->system->platformCommands, debugger->system->platformCommandAliases);
}
if (debugger->system->commands) {
debugger->backend->printf(debugger->backend, "\n%s commands:\n", debugger->system->name);
_printCommands(debugger, debugger->system->commands, debugger->system->commandAliases);
}
}
} else {
_printCommandSummary(debugger, dv->charValue, _debuggerCommands, _debuggerCommandAliases);
if (debugger->system) {
_printCommandSummary(debugger, dv->charValue, debugger->system->platformCommands, debugger->system->platformCommandAliases);
_printCommandSummary(debugger, dv->charValue, debugger->system->commands, debugger->system->commandAliases);
if (debugger->system->platformCommands) {
_printCommandSummary(debugger, dv->charValue, debugger->system->platformCommands, debugger->system->platformCommandAliases);
}
if (debugger->system->commands) {
_printCommandSummary(debugger, dv->charValue, debugger->system->commands, debugger->system->commandAliases);
}
}
}
}
@ -981,8 +989,10 @@ bool CLIDebuggerRunCommand(struct CLIDebugger* debugger, const char* line, size_
}
int result = _tryCommands(debugger, _debuggerCommands, _debuggerCommandAliases, line, cmdLength, args, count - cmdLength - 1);
if (result < 0 && debugger->system) {
result = _tryCommands(debugger, debugger->system->commands, debugger->system->commandAliases, line, cmdLength, args, count - cmdLength - 1);
if (result < 0) {
if (debugger->system->commands) {
result = _tryCommands(debugger, debugger->system->commands, debugger->system->commandAliases, line, cmdLength, args, count - cmdLength - 1);
}
if (result < 0 && debugger->system->platformCommands) {
result = _tryCommands(debugger, debugger->system->platformCommands, debugger->system->platformCommandAliases, line, cmdLength, args, count - cmdLength - 1);
}
}

View File

@ -17,10 +17,6 @@ static void _printStatus(struct CLIDebuggerSystem*);
static void _disassemble(struct CLIDebuggerSystem* debugger, struct CLIDebugVector* dv);
static uint16_t _printLine(struct CLIDebugger* debugger, uint16_t address, int segment);
static struct CLIDebuggerCommandSummary _sm83Commands[] = {
{ 0, 0, 0, 0 }
};
static inline void _printFlags(struct CLIDebuggerBackend* be, union FlagRegister f) {
be->printf(be, "F: [%c%c%c%c]\n",
f.z ? 'Z' : '-',
@ -109,6 +105,6 @@ void SM83CLIDebuggerCreate(struct CLIDebuggerSystem* debugger) {
debugger->printStatus = _printStatus;
debugger->disassemble = _disassemble;
debugger->platformName = "SM83";
debugger->platformCommands = _sm83Commands;
debugger->platformCommands = NULL;
debugger->platformCommandAliases = NULL;
}