svn commit: r320733 - head/sys/ddb
Edward Tomasz Napierala
trasz at FreeBSD.org
Thu Jul 6 12:27:16 UTC 2017
Author: trasz
Date: Thu Jul 6 12:27:14 2017
New Revision: 320733
URL: https://svnweb.freebsd.org/changeset/base/320733
Log:
Make ddb(4) a bit more user-friendly by improving "help".
Obtained from: CheriBSD
MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Modified:
head/sys/ddb/db_command.c
Modified: head/sys/ddb/db_command.c
==============================================================================
--- head/sys/ddb/db_command.c Thu Jul 6 12:19:15 2017 (r320732)
+++ head/sys/ddb/db_command.c Thu Jul 6 12:27:14 2017 (r320733)
@@ -325,11 +325,26 @@ static void
db_cmd_list(struct command_table *table)
{
struct command *cmd;
+ int have_subcommands;
+ have_subcommands = 0;
LIST_FOREACH(cmd, table, next) {
+ if (cmd->more != NULL)
+ have_subcommands++;
db_printf("%-16s", cmd->name);
db_end_line(16);
}
+
+ if (have_subcommands > 0) {
+ db_printf("\nThe following have subcommands; append \"help\" "
+ "to list (e.g. \"show help\"):\n");
+ LIST_FOREACH(cmd, table, next) {
+ if (cmd->more == NULL)
+ continue;
+ db_printf("%-16s", cmd->name);
+ db_end_line(16);
+ }
+ }
}
static void
@@ -371,7 +386,8 @@ db_command(struct command **last_cmdp, struct command_
&cmd);
switch (result) {
case CMD_NONE:
- db_printf("No such command\n");
+ db_printf("No such command; use \"help\" "
+ "to list available commands\n");
db_flush_lex();
return;
case CMD_AMBIGUOUS:
@@ -379,6 +395,13 @@ db_command(struct command **last_cmdp, struct command_
db_flush_lex();
return;
case CMD_HELP:
+ if (cmd_table == &db_cmd_table) {
+ db_printf("This is ddb(4), the kernel debugger; "
+ "see http://man.freebsd.org/ddb/4 for help.\n");
+ db_printf("Use \"bt\" for backtrace, \"dump\" for "
+ "kernel core dump, \"reset\" to reboot.\n");
+ db_printf("Available commands:\n");
+ }
db_cmd_list(cmd_table);
db_flush_lex();
return;
@@ -388,6 +411,8 @@ db_command(struct command **last_cmdp, struct command_
if ((cmd_table = cmd->more) != NULL) {
t = db_read_token();
if (t != tIDENT) {
+ db_printf("Subcommand required; "
+ "available subcommands:\n");
db_cmd_list(cmd_table);
db_flush_lex();
return;
More information about the svn-src-all
mailing list