Date: Wed, 4 Oct 2017 11:53:05 +0000 (UTC) From: Edward Tomasz Napierala <trasz@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324265 - stable/11/sys/ddb Message-ID: <201710041153.v94Br5b6011712@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: trasz Date: Wed Oct 4 11:53:05 2017 New Revision: 324265 URL: https://svnweb.freebsd.org/changeset/base/324265 Log: MFC r320733: Make ddb(4) a bit more user-friendly by improving "help". Modified: stable/11/sys/ddb/db_command.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/ddb/db_command.c ============================================================================== --- stable/11/sys/ddb/db_command.c Wed Oct 4 11:42:12 2017 (r324264) +++ stable/11/sys/ddb/db_command.c Wed Oct 4 11:53:05 2017 (r324265) @@ -312,11 +312,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 @@ -358,7 +373,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: @@ -366,6 +382,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; @@ -375,6 +398,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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201710041153.v94Br5b6011712>