db_command.c: use designated initializers
Provide separate helper macros for regular commands and next-level table commands as they are mutually exclusive. This ensures proper initialization of each element and allows us to exclude some redundant fields, such as specifying .more = NULL for every regular command. Reviewed by: markj, jhb MFC after: 3 days Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D35580
This commit is contained in:
parent
4f2ad6243f
commit
8a09948233
@ -79,84 +79,97 @@ static db_cmdfcn_t db_stack_trace_active;
|
|||||||
static db_cmdfcn_t db_stack_trace_all;
|
static db_cmdfcn_t db_stack_trace_all;
|
||||||
static db_cmdfcn_t db_watchdog;
|
static db_cmdfcn_t db_watchdog;
|
||||||
|
|
||||||
/*
|
#define DB_CMD(_name, _func, _flags) \
|
||||||
* 'show' commands
|
{ \
|
||||||
*/
|
.name = (_name), \
|
||||||
|
.fcn = (_func), \
|
||||||
|
.flag = (_flags), \
|
||||||
|
.more = NULL, \
|
||||||
|
}
|
||||||
|
#define DB_TABLE(_name, _more) \
|
||||||
|
{ \
|
||||||
|
.name = (_name), \
|
||||||
|
.fcn = NULL, \
|
||||||
|
.more = (_more), \
|
||||||
|
}
|
||||||
|
|
||||||
static struct db_command db_show_active_cmds[] = {
|
static struct db_command db_show_active_cmds[] = {
|
||||||
{ "trace", db_stack_trace_active, 0, NULL },
|
DB_CMD("trace", db_stack_trace_active, 0),
|
||||||
};
|
};
|
||||||
struct db_command_table db_show_active_table =
|
struct db_command_table db_show_active_table =
|
||||||
LIST_HEAD_INITIALIZER(db_show_active_table);
|
LIST_HEAD_INITIALIZER(db_show_active_table);
|
||||||
|
|
||||||
static struct db_command db_show_all_cmds[] = {
|
static struct db_command db_show_all_cmds[] = {
|
||||||
{ "trace", db_stack_trace_all, 0, NULL },
|
DB_CMD("trace", db_stack_trace_all, 0),
|
||||||
};
|
};
|
||||||
struct db_command_table db_show_all_table =
|
struct db_command_table db_show_all_table =
|
||||||
LIST_HEAD_INITIALIZER(db_show_all_table);
|
LIST_HEAD_INITIALIZER(db_show_all_table);
|
||||||
|
|
||||||
static struct db_command db_show_cmds[] = {
|
static struct db_command db_show_cmds[] = {
|
||||||
{ "active", 0, 0, &db_show_active_table },
|
DB_TABLE("active", &db_show_active_table),
|
||||||
{ "all", 0, 0, &db_show_all_table },
|
DB_TABLE("all", &db_show_all_table),
|
||||||
{ "registers", db_show_regs, 0, NULL },
|
DB_CMD("registers", db_show_regs, 0),
|
||||||
{ "breaks", db_listbreak_cmd, 0, NULL },
|
DB_CMD("breaks", db_listbreak_cmd, 0),
|
||||||
{ "threads", db_show_threads, 0, NULL },
|
DB_CMD("threads", db_show_threads, 0),
|
||||||
};
|
};
|
||||||
struct db_command_table db_show_table = LIST_HEAD_INITIALIZER(db_show_table);
|
struct db_command_table db_show_table = LIST_HEAD_INITIALIZER(db_show_table);
|
||||||
|
|
||||||
static struct db_command db_cmds[] = {
|
static struct db_command db_cmds[] = {
|
||||||
{ "print", db_print_cmd, 0, NULL },
|
DB_TABLE("show", &db_show_table),
|
||||||
{ "p", db_print_cmd, 0, NULL },
|
DB_CMD("print", db_print_cmd, 0),
|
||||||
{ "examine", db_examine_cmd, CS_SET_DOT, NULL },
|
DB_CMD("p", db_print_cmd, 0),
|
||||||
{ "x", db_examine_cmd, CS_SET_DOT, NULL },
|
DB_CMD("examine", db_examine_cmd, CS_SET_DOT),
|
||||||
{ "search", db_search_cmd, CS_OWN|CS_SET_DOT, NULL },
|
DB_CMD("x", db_examine_cmd, CS_SET_DOT),
|
||||||
{ "set", db_set_cmd, CS_OWN, NULL },
|
DB_CMD("search", db_search_cmd, CS_OWN|CS_SET_DOT),
|
||||||
{ "write", db_write_cmd, CS_MORE|CS_SET_DOT, NULL },
|
DB_CMD("set", db_set_cmd, CS_OWN),
|
||||||
{ "w", db_write_cmd, CS_MORE|CS_SET_DOT, NULL },
|
DB_CMD("write", db_write_cmd, CS_MORE|CS_SET_DOT),
|
||||||
{ "delete", db_delete_cmd, 0, NULL },
|
DB_CMD("w", db_write_cmd, CS_MORE|CS_SET_DOT),
|
||||||
{ "d", db_delete_cmd, 0, NULL },
|
DB_CMD("delete", db_delete_cmd, 0),
|
||||||
{ "dump", db_dump, 0, NULL },
|
DB_CMD("d", db_delete_cmd, 0),
|
||||||
{ "break", db_breakpoint_cmd, 0, NULL },
|
DB_CMD("dump", db_dump, 0),
|
||||||
{ "b", db_breakpoint_cmd, 0, NULL },
|
DB_CMD("break", db_breakpoint_cmd, 0),
|
||||||
{ "dwatch", db_deletewatch_cmd, 0, NULL },
|
DB_CMD("b", db_breakpoint_cmd, 0),
|
||||||
{ "watch", db_watchpoint_cmd, CS_MORE,NULL },
|
DB_CMD("dwatch", db_deletewatch_cmd, 0),
|
||||||
{ "dhwatch", db_deletehwatch_cmd, 0, NULL },
|
DB_CMD("watch", db_watchpoint_cmd, CS_MORE),
|
||||||
{ "hwatch", db_hwatchpoint_cmd, 0, NULL },
|
DB_CMD("dhwatch", db_deletehwatch_cmd, 0),
|
||||||
{ "step", db_single_step_cmd, 0, NULL },
|
DB_CMD("hwatch", db_hwatchpoint_cmd, 0),
|
||||||
{ "s", db_single_step_cmd, 0, NULL },
|
DB_CMD("step", db_single_step_cmd, 0),
|
||||||
{ "continue", db_continue_cmd, 0, NULL },
|
DB_CMD("s", db_single_step_cmd, 0),
|
||||||
{ "c", db_continue_cmd, 0, NULL },
|
DB_CMD("continue", db_continue_cmd, 0),
|
||||||
{ "until", db_trace_until_call_cmd,0, NULL },
|
DB_CMD("c", db_continue_cmd, 0),
|
||||||
{ "next", db_trace_until_matching_cmd,0, NULL },
|
DB_CMD("until", db_trace_until_call_cmd, 0),
|
||||||
{ "match", db_trace_until_matching_cmd,0, NULL },
|
DB_CMD("next", db_trace_until_matching_cmd, 0),
|
||||||
{ "trace", db_stack_trace, CS_OWN, NULL },
|
DB_CMD("match", db_trace_until_matching_cmd, 0),
|
||||||
{ "t", db_stack_trace, CS_OWN, NULL },
|
DB_CMD("trace", db_stack_trace, CS_OWN),
|
||||||
|
DB_CMD("t", db_stack_trace, CS_OWN),
|
||||||
/* XXX alias for active trace */
|
/* XXX alias for active trace */
|
||||||
{ "acttrace", db_stack_trace_active, 0, NULL },
|
DB_CMD("acttrace", db_stack_trace_active, 0),
|
||||||
/* XXX alias for all trace */
|
/* XXX alias for all trace */
|
||||||
{ "alltrace", db_stack_trace_all, 0, NULL },
|
DB_CMD("alltrace", db_stack_trace_all, 0),
|
||||||
{ "where", db_stack_trace, CS_OWN, NULL },
|
DB_CMD("where", db_stack_trace, CS_OWN),
|
||||||
{ "bt", db_stack_trace, CS_OWN, NULL },
|
DB_CMD("bt", db_stack_trace, CS_OWN),
|
||||||
{ "call", db_fncall, CS_OWN, NULL },
|
DB_CMD("call", db_fncall, CS_OWN),
|
||||||
{ "show", 0, 0, &db_show_table },
|
DB_CMD("ps", db_ps, 0),
|
||||||
{ "ps", db_ps, 0, NULL },
|
DB_CMD("gdb", db_gdb, 0),
|
||||||
{ "gdb", db_gdb, 0, NULL },
|
DB_CMD("halt", db_halt, 0),
|
||||||
{ "halt", db_halt, 0, NULL },
|
DB_CMD("reboot", db_reset, 0),
|
||||||
{ "reboot", db_reset, 0, NULL },
|
DB_CMD("reset", db_reset, 0),
|
||||||
{ "reset", db_reset, 0, NULL },
|
DB_CMD("kill", db_kill, CS_OWN),
|
||||||
{ "kill", db_kill, CS_OWN, NULL },
|
DB_CMD("watchdog", db_watchdog, CS_OWN),
|
||||||
{ "watchdog", db_watchdog, CS_OWN, NULL },
|
DB_CMD("thread", db_set_thread, 0),
|
||||||
{ "thread", db_set_thread, 0, NULL },
|
DB_CMD("run", db_run_cmd, CS_OWN),
|
||||||
{ "run", db_run_cmd, CS_OWN, NULL },
|
DB_CMD("script", db_script_cmd, CS_OWN),
|
||||||
{ "script", db_script_cmd, CS_OWN, NULL },
|
DB_CMD("scripts", db_scripts_cmd, 0),
|
||||||
{ "scripts", db_scripts_cmd, 0, NULL },
|
DB_CMD("unscript", db_unscript_cmd, CS_OWN),
|
||||||
{ "unscript", db_unscript_cmd, CS_OWN, NULL },
|
DB_CMD("capture", db_capture_cmd, CS_OWN),
|
||||||
{ "capture", db_capture_cmd, CS_OWN, NULL },
|
DB_CMD("textdump", db_textdump_cmd, CS_OWN),
|
||||||
{ "textdump", db_textdump_cmd, CS_OWN, NULL },
|
DB_CMD("findstack", db_findstack_cmd, 0),
|
||||||
{ "findstack", db_findstack_cmd, 0, NULL },
|
|
||||||
};
|
};
|
||||||
struct db_command_table db_cmd_table = LIST_HEAD_INITIALIZER(db_cmd_table);
|
struct db_command_table db_cmd_table = LIST_HEAD_INITIALIZER(db_cmd_table);
|
||||||
|
|
||||||
|
#undef DB_CMD
|
||||||
|
#undef DB_TABLE
|
||||||
|
|
||||||
static struct db_command *db_last_command = NULL;
|
static struct db_command *db_last_command = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user