Changed the "help" command to be able to only show all commands starting with a certain string.
This helps to reduce the flood of commands for those blue screen "users" :-) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13018 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -63,7 +63,7 @@ static char *args[MAX_ARGS] = { NULL, };
|
|||||||
|
|
||||||
|
|
||||||
static debugger_command *
|
static debugger_command *
|
||||||
find_command(char *name)
|
find_command(char *name, bool partialMatch)
|
||||||
{
|
{
|
||||||
debugger_command *command;
|
debugger_command *command;
|
||||||
int length;
|
int length;
|
||||||
@@ -77,11 +77,13 @@ find_command(char *name)
|
|||||||
|
|
||||||
// if it couldn't be found, search for a partial match
|
// if it couldn't be found, search for a partial match
|
||||||
|
|
||||||
length = strlen(name);
|
if (partialMatch) {
|
||||||
|
length = strlen(name);
|
||||||
|
|
||||||
for (command = sCommands; command != NULL; command = command->next) {
|
for (command = sCommands; command != NULL; command = command->next) {
|
||||||
if (strncmp(name, command->name, length) == 0)
|
if (strncmp(name, command->name, length) == 0)
|
||||||
return command;
|
return command;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -263,7 +265,7 @@ kernel_debugger_loop(void)
|
|||||||
sDebuggerOnCPU = smp_get_current_cpu();
|
sDebuggerOnCPU = smp_get_current_cpu();
|
||||||
|
|
||||||
if (argc > 0)
|
if (argc > 0)
|
||||||
cmd = find_command(args[0]);
|
cmd = find_command(args[0], true);
|
||||||
|
|
||||||
if (cmd == NULL)
|
if (cmd == NULL)
|
||||||
dprintf("unknown command, enter \"help\" to get a list of all supported commands\n");
|
dprintf("unknown command, enter \"help\" to get a list of all supported commands\n");
|
||||||
@@ -297,19 +299,30 @@ static int
|
|||||||
cmd_help(int argc, char **argv)
|
cmd_help(int argc, char **argv)
|
||||||
{
|
{
|
||||||
debugger_command *command, *specified = NULL;
|
debugger_command *command, *specified = NULL;
|
||||||
|
const char *start = NULL;
|
||||||
|
int32 startLength = 0;
|
||||||
|
|
||||||
if (argc > 1)
|
if (argc > 1) {
|
||||||
specified = find_command(argv[1]);
|
specified = find_command(argv[1], false);
|
||||||
|
if (specified == NULL) {
|
||||||
|
start = argv[1];
|
||||||
|
startLength = strlen(start);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (specified != NULL) {
|
if (specified != NULL) {
|
||||||
// only print out the help of the specified command (and all of its aliases)
|
// only print out the help of the specified command (and all of its aliases)
|
||||||
dprintf("debugger command for \"%s\" and aliases:\n", specified->name);
|
dprintf("debugger command for \"%s\" and aliases:\n", specified->name);
|
||||||
} else
|
} else if (start != NULL)
|
||||||
|
dprintf("debugger commands starting with \"%s\":\n", start);
|
||||||
|
else
|
||||||
dprintf("debugger commands:\n");
|
dprintf("debugger commands:\n");
|
||||||
|
|
||||||
for (command = sCommands; command != NULL; command = command->next) {
|
for (command = sCommands; command != NULL; command = command->next) {
|
||||||
if (specified && command->func != specified->func)
|
if (specified && command->func != specified->func)
|
||||||
continue;
|
continue;
|
||||||
|
if (start != NULL && strncmp(start, command->name, startLength))
|
||||||
|
continue;
|
||||||
|
|
||||||
dprintf(" %-20s\t\t%s\n", command->name, command->description ? command->description : "-");
|
dprintf(" %-20s\t\t%s\n", command->name, command->description ? command->description : "-");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user