diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-05-27 13:59:01 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-05-27 14:00:07 -0400 |
commit | 3947f654eabb1b6ccf8aad11ece46dc4b027f0f0 (patch) | |
tree | ce1f687f4929daf2ce5aa10741c244cb1ab6e7ab /gdb | |
parent | 7bd22f56a3cf47c6743f7f7989a6fa07f935d31b (diff) | |
download | gdb-3947f654eabb1b6ccf8aad11ece46dc4b027f0f0.zip gdb-3947f654eabb1b6ccf8aad11ece46dc4b027f0f0.tar.gz gdb-3947f654eabb1b6ccf8aad11ece46dc4b027f0f0.tar.bz2 |
gdb: make add_com_alias accept target as a cmd_list_element
The alias creation functions currently accept a name to specify the
target command. They pass this to add_alias_cmd, which needs to lookup
the target command by name.
Given that:
- We don't support creating an alias for a command before that command
exists.
- We always use add_info_alias just after creating that target command,
and therefore have access to the target command's cmd_list_element.
... change add_com_alias to accept the target command as a
cmd_list_element (other functions are done in subsequent patches). This
ensures we don't create the alias before the target command, because you
need to get the cmd_list_element from somewhere when you call the alias
creation function. And it avoids an unecessary command lookup. So it
seems better to me in every aspect.
gdb/ChangeLog:
* command.h (add_com_alias): Accept target as
cmd_list_element. Update callers.
Change-Id: I24bed7da57221cc77606034de3023fedac015150
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/breakpoint.c | 63 | ||||
-rw-r--r-- | gdb/cli/cli-cmds.c | 64 | ||||
-rw-r--r-- | gdb/cli/cli-decode.c | 6 | ||||
-rw-r--r-- | gdb/command.h | 6 | ||||
-rw-r--r-- | gdb/compile/compile.c | 2 | ||||
-rw-r--r-- | gdb/gcore.c | 5 | ||||
-rw-r--r-- | gdb/guile/guile.c | 8 | ||||
-rw-r--r-- | gdb/infcmd.c | 53 | ||||
-rw-r--r-- | gdb/maint.c | 9 | ||||
-rw-r--r-- | gdb/objc-lang.c | 7 | ||||
-rw-r--r-- | gdb/printcmd.c | 9 | ||||
-rw-r--r-- | gdb/python/python.c | 9 | ||||
-rw-r--r-- | gdb/record.c | 7 | ||||
-rw-r--r-- | gdb/regcache.c | 9 | ||||
-rw-r--r-- | gdb/reverse.c | 37 | ||||
-rw-r--r-- | gdb/source.c | 21 | ||||
-rw-r--r-- | gdb/stack.c | 28 | ||||
-rw-r--r-- | gdb/symfile.c | 11 | ||||
-rw-r--r-- | gdb/thread.c | 9 | ||||
-rw-r--r-- | gdb/tracepoint.c | 4 | ||||
-rw-r--r-- | gdb/tui/tui-win.c | 20 |
22 files changed, 219 insertions, 173 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7e06361..5b04413 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2021-05-27 Simon Marchi <simon.marchi@polymtl.ca> + * command.h (add_com_alias): Accept target as + cmd_list_element. Update callers. + +2021-05-27 Simon Marchi <simon.marchi@polymtl.ca> + * python/py-param.c (add_setshow_generic): Use return values of add_setshow functions. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index d479f00..1df0080 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -15724,16 +15724,17 @@ so it will be deleted when hit.\n\ BREAK_ARGS_HELP ("thbreak"))); set_cmd_completer (c, location_completer); - add_prefix_cmd ("enable", class_breakpoint, enable_command, _("\ + cmd_list_element *enable_cmd + = add_prefix_cmd ("enable", class_breakpoint, enable_command, _("\ Enable all or some breakpoints.\n\ Usage: enable [BREAKPOINTNUM]...\n\ Give breakpoint numbers (separated by spaces) as arguments.\n\ With no subcommand, breakpoints are enabled until you command otherwise.\n\ This is used to cancel the effect of the \"disable\" command.\n\ With a subcommand you can enable temporarily."), - &enablelist, 1, &cmdlist); + &enablelist, 1, &cmdlist); - add_com_alias ("en", "enable", class_breakpoint, 1); + add_com_alias ("en", enable_cmd, class_breakpoint, 1); add_prefix_cmd ("breakpoints", class_breakpoint, enable_command, _("\ Enable all or some breakpoints.\n\ @@ -15781,15 +15782,16 @@ If a breakpoint is hit while enabled in this fashion,\n\ the count is decremented; when it reaches zero, the breakpoint is disabled."), &enablelist); - add_prefix_cmd ("disable", class_breakpoint, disable_command, _("\ + cmd_list_element *disable_cmd + = add_prefix_cmd ("disable", class_breakpoint, disable_command, _("\ Disable all or some breakpoints.\n\ Usage: disable [BREAKPOINTNUM]...\n\ Arguments are breakpoint numbers with spaces in between.\n\ To disable all breakpoints, give no argument.\n\ A disabled breakpoint is not forgotten, but has no effect until re-enabled."), - &disablelist, 1, &cmdlist); - add_com_alias ("dis", "disable", class_breakpoint, 1); - add_com_alias ("disa", "disable", class_breakpoint, 1); + &disablelist, 1, &cmdlist); + add_com_alias ("dis", disable_cmd, class_breakpoint, 1); + add_com_alias ("disa", disable_cmd, class_breakpoint, 1); add_cmd ("breakpoints", class_breakpoint, disable_command, _("\ Disable all or some breakpoints.\n\ @@ -15800,16 +15802,17 @@ A disabled breakpoint is not forgotten, but has no effect until re-enabled.\n\ This command may be abbreviated \"disable\"."), &disablelist); - add_prefix_cmd ("delete", class_breakpoint, delete_command, _("\ + cmd_list_element *delete_cmd + = add_prefix_cmd ("delete", class_breakpoint, delete_command, _("\ Delete all or some breakpoints.\n\ Usage: delete [BREAKPOINTNUM]...\n\ Arguments are breakpoint numbers with spaces in between.\n\ To delete all breakpoints, give no argument.\n\ \n\ Also a prefix command for deletion of other GDB objects."), - &deletelist, 1, &cmdlist); - add_com_alias ("d", "delete", class_breakpoint, 1); - add_com_alias ("del", "delete", class_breakpoint, 1); + &deletelist, 1, &cmdlist); + add_com_alias ("d", delete_cmd, class_breakpoint, 1); + add_com_alias ("del", delete_cmd, class_breakpoint, 1); add_cmd ("breakpoints", class_breakpoint, delete_command, _("\ Delete all or some breakpoints or auto-display expressions.\n\ @@ -15819,7 +15822,8 @@ To delete all breakpoints, give no argument.\n\ This command may be abbreviated \"delete\"."), &deletelist); - add_com ("clear", class_breakpoint, clear_command, _("\ + cmd_list_element *clear_cmd + = add_com ("clear", class_breakpoint, clear_command, _("\ Clear breakpoint at specified location.\n\ Argument may be a linespec, explicit, or address location as described below.\n\ \n\ @@ -15827,17 +15831,18 @@ With no argument, clears all breakpoints in the line that the selected frame\n\ is executing in.\n" "\n" LOCATION_HELP_STRING "\n\n\ See also the \"delete\" command which clears breakpoints by number.")); - add_com_alias ("cl", "clear", class_breakpoint, 1); + add_com_alias ("cl", clear_cmd, class_breakpoint, 1); - c = add_com ("break", class_breakpoint, break_command, _("\ + cmd_list_element *break_cmd + = add_com ("break", class_breakpoint, break_command, _("\ Set breakpoint at specified location.\n" BREAK_ARGS_HELP ("break"))); - set_cmd_completer (c, location_completer); + set_cmd_completer (break_cmd, location_completer); - add_com_alias ("b", "break", class_run, 1); - add_com_alias ("br", "break", class_run, 1); - add_com_alias ("bre", "break", class_run, 1); - add_com_alias ("brea", "break", class_run, 1); + add_com_alias ("b", break_cmd, class_run, 1); + add_com_alias ("br", break_cmd, class_run, 1); + add_com_alias ("bre", break_cmd, class_run, 1); + add_com_alias ("brea", break_cmd, class_run, 1); if (dbx_commands) { @@ -16006,17 +16011,18 @@ hardware.)"), /* Tracepoint manipulation commands. */ - c = add_com ("trace", class_breakpoint, trace_command, _("\ + cmd_list_element *trace_cmd + = add_com ("trace", class_breakpoint, trace_command, _("\ Set a tracepoint at specified location.\n\ \n" BREAK_ARGS_HELP ("trace") "\n\ Do \"help tracepoints\" for info on other tracepoint commands.")); - set_cmd_completer (c, location_completer); + set_cmd_completer (trace_cmd, location_completer); - add_com_alias ("tp", "trace", class_breakpoint, 0); - add_com_alias ("tr", "trace", class_breakpoint, 1); - add_com_alias ("tra", "trace", class_breakpoint, 1); - add_com_alias ("trac", "trace", class_breakpoint, 1); + add_com_alias ("tp", trace_cmd, class_breakpoint, 0); + add_com_alias ("tr", trace_cmd, class_breakpoint, 1); + add_com_alias ("tra", trace_cmd, class_breakpoint, 1); + add_com_alias ("trac", trace_cmd, class_breakpoint, 1); c = add_com ("ftrace", class_breakpoint, ftrace_command, _("\ Set a fast tracepoint at specified location.\n\ @@ -16094,13 +16100,14 @@ session to restore them."), &save_cmdlist); set_cmd_completer (c, filename_completer); - c = add_cmd ("tracepoints", class_trace, save_tracepoints_command, _("\ + cmd_list_element *save_tracepoints_cmd + = add_cmd ("tracepoints", class_trace, save_tracepoints_command, _("\ Save current tracepoint definitions as a script.\n\ Use the 'source' command in another debug session to restore them."), &save_cmdlist); - set_cmd_completer (c, filename_completer); + set_cmd_completer (save_tracepoints_cmd, filename_completer); - c = add_com_alias ("save-tracepoints", "save tracepoints", class_trace, 0); + c = add_com_alias ("save-tracepoints", save_tracepoints_cmd, class_trace, 0); deprecate_cmd (c, "save tracepoints"); add_basic_prefix_cmd ("breakpoint", class_maintenance, _("\ diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 0bf418e..8b2aa5a 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -1750,19 +1750,20 @@ argv_to_string (char **argv, int n) and the user would expect bbb to execute 'backtrace -full -past-main' while it will execute 'backtrace -past-main'. */ -static void +static cmd_list_element * validate_aliased_command (const char *command) { - struct cmd_list_element *c; std::string default_args; - - c = lookup_cmd_1 (& command, cmdlist, NULL, &default_args, 1); + cmd_list_element *c + = lookup_cmd_1 (& command, cmdlist, NULL, &default_args, 1); if (c == NULL || c == (struct cmd_list_element *) -1) error (_("Invalid command to alias to: %s"), command); if (!default_args.empty ()) error (_("Cannot define an alias of an alias that has default args")); + + return c; } /* Called when "alias" was incorrectly used. */ @@ -1832,7 +1833,7 @@ alias_command (const char *args, int from_tty) std::string command_string (argv_to_string (command_argv.get (), command_argc)); command = command_string.c_str (); - validate_aliased_command (command); + cmd_list_element *target_cmd = validate_aliased_command (command); /* ALIAS must not exist. */ std::string alias_string (argv_to_string (alias_argv, alias_argc)); @@ -1875,8 +1876,8 @@ alias_command (const char *args, int from_tty) if (alias_argc == 1) { /* add_cmd requires *we* allocate space for name, hence the xstrdup. */ - alias_cmd = add_com_alias (xstrdup (alias_argv[0]), command, class_alias, - a_opts.abbrev_flag); + alias_cmd = add_com_alias (xstrdup (alias_argv[0]), target_cmd, + class_alias, a_opts.abbrev_flag); } else { @@ -2332,16 +2333,18 @@ strict == evaluate script according to filename extension, error if not supporte show_script_ext_mode, &setlist, &showlist); - add_com ("quit", class_support, quit_command, _("\ + cmd_list_element *quit_cmd + = add_com ("quit", class_support, quit_command, _("\ Exit gdb.\n\ Usage: quit [EXPR]\n\ The optional expression EXPR, if present, is evaluated and the result\n\ used as GDB's exit code. The default is zero.")); - c = add_com ("help", class_support, help_command, + cmd_list_element *help_cmd + = add_com ("help", class_support, help_command, _("Print list of commands.")); - set_cmd_completer (c, command_completer); - add_com_alias ("q", "quit", class_support, 1); - add_com_alias ("h", "help", class_support, 1); + set_cmd_completer (help_cmd, command_completer); + add_com_alias ("q", quit_cmd, class_support, 1); + add_com_alias ("h", help_cmd, class_support, 1); add_setshow_boolean_cmd ("verbose", class_support, &info_verbose, _("\ Set verbosity."), _("\ @@ -2365,11 +2368,12 @@ Without an argument, history expansion is enabled."), show_history_expansion_p, &sethistlist, &showhistlist); - add_prefix_cmd ("info", class_info, info_command, _("\ + cmd_list_element *info_cmd + = add_prefix_cmd ("info", class_info, info_command, _("\ Generic command for showing things about the program being debugged."), - &infolist, 0, &cmdlist); - add_com_alias ("i", "info", class_info, 1); - add_com_alias ("inf", "info", class_info, 1); + &infolist, 0, &cmdlist); + add_com_alias ("i", info_cmd, class_info, 1); + add_com_alias ("inf", info_cmd, class_info, 1); add_com ("complete", class_obscure, complete_command, _("List the completions for the rest of the line as a command.")); @@ -2380,7 +2384,8 @@ Generic command for showing things about the debugger."), /* Another way to get at the same thing. */ add_alias_cmd ("set", c, class_info, 0, &infolist); - c = add_com ("with", class_vars, with_command, _("\ + cmd_list_element *with_cmd + = add_com ("with", class_vars, with_command, _("\ Temporarily set SETTING to VALUE, run COMMAND, and restore SETTING.\n\ Usage: with SETTING [VALUE] [-- COMMAND]\n\ Usage: w SETTING [VALUE] [-- COMMAND]\n\ @@ -2394,8 +2399,8 @@ E.g.:\n\ You can change multiple settings using nested with, and use\n\ abbreviations for commands and/or values. E.g.:\n\ w la p -- w p el u -- p obj")); - set_cmd_completer_handle_brkchars (c, with_command_completer); - add_com_alias ("w", "with", class_vars, 1); + set_cmd_completer_handle_brkchars (with_cmd, with_command_completer); + add_com_alias ("w", with_cmd, class_vars, 1); add_internal_function ("_gdb_setting_str", _("\ $_gdb_setting_str - returns the value of a GDB setting as a string.\n\ @@ -2455,12 +2460,13 @@ the previous command number shown."), _("Generic command for showing gdb debugging flags."), &showdebuglist, 0, &showlist); - c = add_com ("shell", class_support, shell_command, _("\ + cmd_list_element *shell_cmd + = add_com ("shell", class_support, shell_command, _("\ Execute the rest of the line as a shell command.\n\ With no arguments, run an inferior shell.")); - set_cmd_completer (c, filename_completer); + set_cmd_completer (shell_cmd, filename_completer); - add_com_alias ("!", "shell", class_support, 0); + add_com_alias ("!", shell_cmd, class_support, 0); c = add_com ("edit", class_files, edit_command, _("\ Edit specified file or function.\n\ @@ -2474,7 +2480,8 @@ Uses EDITOR environment variable contents as editor (or ex as default).")); c->completer = location_completer; - c = add_com ("pipe", class_support, pipe_command, _("\ + cmd_list_element *pipe_cmd + = add_com ("pipe", class_support, pipe_command, _("\ Send the output of a gdb command to a shell command.\n\ Usage: | [COMMAND] | SHELL_COMMAND\n\ Usage: | -d DELIM COMMAND DELIM SHELL_COMMAND\n\ @@ -2489,10 +2496,11 @@ case COMMAND contains a | character.\n\ \n\ With no COMMAND, repeat the last executed command\n\ and send its output to SHELL_COMMAND.")); - set_cmd_completer_handle_brkchars (c, pipe_command_completer); - add_com_alias ("|", "pipe", class_support, 0); + set_cmd_completer_handle_brkchars (pipe_cmd, pipe_command_completer); + add_com_alias ("|", pipe_cmd, class_support, 0); - add_com ("list", class_files, list_command, _("\ + cmd_list_element *list_cmd + = add_com ("list", class_files, list_command, _("\ List specified function or line.\n\ With no argument, lists ten more lines after or around previous listing.\n\ \"list -\" lists the ten lines before a previous ten-line listing.\n\ @@ -2511,10 +2519,10 @@ By default, when a single location is given, display ten lines.\n\ This can be changed using \"set listsize\", and the current value\n\ can be shown using \"show listsize\".")); - add_com_alias ("l", "list", class_files, 1); + add_com_alias ("l", list_cmd, class_files, 1); if (dbx_commands) - add_com_alias ("file", "list", class_files, 1); + add_com_alias ("file", list_cmd, class_files, 1); c = add_com ("disassemble", class_vars, disassemble_command, _("\ Disassemble a specified section of memory.\n\ diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 0482cca..dd64996 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -1007,11 +1007,11 @@ add_com (const char *name, enum command_class theclass, different of class_alias, as class_alias is used to identify user defined aliases. */ -struct cmd_list_element * -add_com_alias (const char *name, const char *target_name, +cmd_list_element * +add_com_alias (const char *name, cmd_list_element *target, command_class theclass, int abbrev_flag) { - return add_alias_cmd (name, target_name, theclass, abbrev_flag, &cmdlist); + return add_alias_cmd (name, target, theclass, abbrev_flag, &cmdlist); } /* Add an element with a suppress notification to the list of commands. */ diff --git a/gdb/command.h b/gdb/command.h index e82f2ea..638de1e 100644 --- a/gdb/command.h +++ b/gdb/command.h @@ -359,8 +359,10 @@ extern struct cmd_list_element *add_com (const char *, enum command_class, cmd_const_cfunc_ftype *fun, const char *); -extern struct cmd_list_element *add_com_alias (const char *, const char *, - enum command_class, int); +extern cmd_list_element *add_com_alias (const char *name, + cmd_list_element *target, + command_class theclass, + int abbrev_flag); extern struct cmd_list_element *add_com_suppress_notification (const char *name, enum command_class theclass, diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c index c7f7d38..8481d14 100644 --- a/gdb/compile/compile.c +++ b/gdb/compile/compile.c @@ -931,7 +931,7 @@ _initialize_compile () compile_command, _("\ Command to compile source code and inject it into the inferior."), &compile_command_list, 1, &cmdlist); - add_com_alias ("expression", "compile", class_obscure, 0); + add_com_alias ("expression", compile_cmd_element, class_obscure, 0); const auto compile_opts = make_compile_options_def_group (nullptr); diff --git a/gdb/gcore.c b/gdb/gcore.c index 3b90253..76e856d 100644 --- a/gdb/gcore.c +++ b/gdb/gcore.c @@ -604,10 +604,11 @@ void _initialize_gcore (); void _initialize_gcore () { - add_com ("generate-core-file", class_files, gcore_command, _("\ + cmd_list_element *generate_core_file_cmd + = add_com ("generate-core-file", class_files, gcore_command, _("\ Save a core file with the current state of the debugged process.\n\ Usage: generate-core-file [FILENAME]\n\ Argument is optional filename. Default filename is 'core.PROCESS_ID'.")); - add_com_alias ("gcore", "generate-core-file", class_files, 1); + add_com_alias ("gcore", generate_core_file_cmd, class_files, 1); } diff --git a/gdb/guile/guile.c b/gdb/guile/guile.c index 0166355..a707c89 100644 --- a/gdb/guile/guile.c +++ b/gdb/guile/guile.c @@ -726,8 +726,8 @@ cmd_list_element *guile_cmd_element = nullptr; static void install_gdb_commands (void) { - add_com ("guile-repl", class_obscure, - guile_repl_command, + cmd_list_element *guile_repl_cmd + = add_com ("guile-repl", class_obscure, guile_repl_command, #ifdef HAVE_GUILE _("\ Start an interactive Guile prompt.\n\ @@ -742,7 +742,7 @@ Guile scripting is not supported in this copy of GDB.\n\ This command is only a placeholder.") #endif /* HAVE_GUILE */ ); - add_com_alias ("gr", "guile-repl", class_obscure, 1); + add_com_alias ("gr", guile_repl_cmd, class_obscure, 1); /* Since "help guile" is easy to type, and intuitive, we add general help in using GDB+Guile to this command. */ @@ -778,7 +778,7 @@ Guile scripting is not supported in this copy of GDB.\n\ This command is only a placeholder.") #endif /* HAVE_GUILE */ ); - add_com_alias ("gu", "guile", class_obscure, 1); + add_com_alias ("gu", guile_cmd_element, class_obscure, 1); add_basic_prefix_cmd ("guile", class_obscure, _("Prefix command for Guile preference settings."), diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 4351409..07d69b4 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -3174,48 +3174,54 @@ In a multi-threaded program the signal is queued with, or discarded from,\n\ the current thread only.")); set_cmd_completer (c, signal_completer); - add_com ("stepi", class_run, stepi_command, _("\ + cmd_list_element *stepi_cmd + = add_com ("stepi", class_run, stepi_command, _("\ Step one instruction exactly.\n\ Usage: stepi [N]\n\ Argument N means step N times (or till program stops for another \ reason).")); - add_com_alias ("si", "stepi", class_run, 0); + add_com_alias ("si", stepi_cmd, class_run, 0); - add_com ("nexti", class_run, nexti_command, _("\ + cmd_list_element *nexti_cmd + = add_com ("nexti", class_run, nexti_command, _("\ Step one instruction, but proceed through subroutine calls.\n\ Usage: nexti [N]\n\ Argument N means step N times (or till program stops for another \ reason).")); - add_com_alias ("ni", "nexti", class_run, 0); + add_com_alias ("ni", nexti_cmd, class_run, 0); - add_com ("finish", class_run, finish_command, _("\ + cmd_list_element *finish_cmd + = add_com ("finish", class_run, finish_command, _("\ Execute until selected stack frame returns.\n\ Usage: finish\n\ Upon return, the value returned is printed and put in the value history.")); - add_com_alias ("fin", "finish", class_run, 1); + add_com_alias ("fin", finish_cmd, class_run, 1); - add_com ("next", class_run, next_command, _("\ + cmd_list_element *next_cmd + = add_com ("next", class_run, next_command, _("\ Step program, proceeding through subroutine calls.\n\ Usage: next [N]\n\ Unlike \"step\", if the current source line calls a subroutine,\n\ this command does not enter the subroutine, but instead steps over\n\ the call, in effect treating it as a single source line.")); - add_com_alias ("n", "next", class_run, 1); + add_com_alias ("n", next_cmd, class_run, 1); - add_com ("step", class_run, step_command, _("\ + cmd_list_element *step_cmd + = add_com ("step", class_run, step_command, _("\ Step program until it reaches a different source line.\n\ Usage: step [N]\n\ Argument N means step N times (or till program stops for another \ reason).")); - add_com_alias ("s", "step", class_run, 1); + add_com_alias ("s", step_cmd, class_run, 1); - c = add_com ("until", class_run, until_command, _("\ + cmd_list_element *until_cmd + = add_com ("until", class_run, until_command, _("\ Execute until past the current line or past a LOCATION.\n\ Execute until the program reaches a source line greater than the current\n\ or a specified location (same args as break command) within the current \ frame.")); - set_cmd_completer (c, location_completer); - add_com_alias ("u", "until", class_run, 1); + set_cmd_completer (until_cmd, location_completer); + add_com_alias ("u", until_cmd, class_run, 1); c = add_com ("advance", class_run, advance_command, _("\ Continue the program up to the given location (same form as args for break \ @@ -3223,15 +3229,17 @@ command).\n\ Execution will also stop upon exit from the current stack frame.")); set_cmd_completer (c, location_completer); - c = add_com ("jump", class_run, jump_command, _("\ + cmd_list_element *jump_cmd + = add_com ("jump", class_run, jump_command, _("\ Continue program being debugged at specified line or address.\n\ Usage: jump LOCATION\n\ Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\ for an address to start at.")); - set_cmd_completer (c, location_completer); - add_com_alias ("j", "jump", class_run, 1); + set_cmd_completer (jump_cmd, location_completer); + add_com_alias ("j", jump_cmd, class_run, 1); - add_com ("continue", class_run, continue_command, _("\ + cmd_list_element *continue_cmd + = add_com ("continue", class_run, continue_command, _("\ Continue program being debugged, after signal or breakpoint.\n\ Usage: continue [N]\n\ If proceeding from breakpoint, a number N may be used as an argument,\n\ @@ -3242,14 +3250,15 @@ If non-stop mode is enabled, continue only the current thread,\n\ otherwise all the threads in the program are continued. To \n\ continue all stopped threads in non-stop mode, use the -a option.\n\ Specifying -a and an ignore count simultaneously is an error.")); - add_com_alias ("c", "cont", class_run, 1); - add_com_alias ("fg", "cont", class_run, 1); + add_com_alias ("c", continue_cmd, class_run, 1); + add_com_alias ("fg", continue_cmd, class_run, 1); - c = add_com ("run", class_run, run_command, _("\ + cmd_list_element *run_cmd + = add_com ("run", class_run, run_command, _("\ Start debugged program.\n" RUN_ARGS_HELP)); - set_cmd_completer (c, filename_completer); - add_com_alias ("r", "run", class_run, 1); + set_cmd_completer (run_cmd, filename_completer); + add_com_alias ("r", run_cmd, class_run, 1); c = add_com ("start", class_run, start_command, _("\ Start the debugged program stopping at the beginning of the main procedure.\n" diff --git a/gdb/maint.c b/gdb/maint.c index 154bef5..91a7f77 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -1133,14 +1133,15 @@ _initialize_maint_cmds () { struct cmd_list_element *cmd; - add_basic_prefix_cmd ("maintenance", class_maintenance, _("\ + cmd_list_element *maintenance_cmd + = add_basic_prefix_cmd ("maintenance", class_maintenance, _("\ Commands for use by GDB maintainers.\n\ Includes commands to dump specific internal GDB structures in\n\ a human readable form, to cause GDB to deliberately dump core, etc."), - &maintenancelist, 0, - &cmdlist); + &maintenancelist, 0, + &cmdlist); - add_com_alias ("mt", "maintenance", class_maintenance, 1); + add_com_alias ("mt", maintenance_cmd, class_maintenance, 1); add_basic_prefix_cmd ("info", class_maintenance, _("\ Commands for showing internal info about the program being debugged."), diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index 1d44012..077ac77 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -1319,9 +1319,10 @@ _initialize_objc_language () _("All Objective-C selectors, or those matching REGEXP.")); add_info ("classes", info_classes_command, _("All Objective-C classes, or those matching REGEXP.")); - add_com ("print-object", class_vars, print_object_command, - _("Ask an Objective-C object to print itself.")); - add_com_alias ("po", "print-object", class_vars, 1); + cmd_list_element *print_object_cmd + = add_com ("print-object", class_vars, print_object_command, + _("Ask an Objective-C object to print itself.")); + add_com_alias ("po", print_object_cmd, class_vars, 1); } static void diff --git a/gdb/printcmd.c b/gdb/printcmd.c index a5c03c3..8daa87c 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -3351,10 +3351,11 @@ EXP may be preceded with /FMT, where FMT is a format letter\n\ but no count or size letter (see \"x\" command)."), print_opts); - c = add_com ("print", class_vars, print_command, print_help.c_str ()); - set_cmd_completer_handle_brkchars (c, print_command_completer); - add_com_alias ("p", "print", class_vars, 1); - add_com_alias ("inspect", "print", class_vars, 1); + cmd_list_element *print_cmd + = add_com ("print", class_vars, print_command, print_help.c_str ()); + set_cmd_completer_handle_brkchars (print_cmd, print_command_completer); + add_com_alias ("p", print_cmd, class_vars, 1); + add_com_alias ("inspect", print_cmd, class_vars, 1); add_setshow_uinteger_cmd ("max-symbolic-offset", no_class, &max_symbolic_offset, _("\ diff --git a/gdb/python/python.c b/gdb/python/python.c index 4cea83c..e42cbc4 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -1886,8 +1886,9 @@ void _initialize_python (); void _initialize_python () { - add_com ("python-interactive", class_obscure, - python_interactive_command, + cmd_list_element *python_interactive_cmd + = add_com ("python-interactive", class_obscure, + python_interactive_command, #ifdef HAVE_PYTHON _("\ Start an interactive Python prompt.\n\ @@ -1909,7 +1910,7 @@ Python scripting is not supported in this copy of GDB.\n\ This command is only a placeholder.") #endif /* HAVE_PYTHON */ ); - add_com_alias ("pi", "python-interactive", class_obscure, 1); + add_com_alias ("pi", python_interactive_cmd, class_obscure, 1); python_cmd_element = add_com ("python", class_obscure, python_command, #ifdef HAVE_PYTHON @@ -1931,7 +1932,7 @@ Python scripting is not supported in this copy of GDB.\n\ This command is only a placeholder.") #endif /* HAVE_PYTHON */ ); - add_com_alias ("py", "python", class_obscure, 1); + add_com_alias ("py", python_cmd_element, class_obscure, 1); /* Add set/show python print-stack. */ add_basic_prefix_cmd ("python", no_class, diff --git a/gdb/record.c b/gdb/record.c index 7dae18f..a09137b 100644 --- a/gdb/record.c +++ b/gdb/record.c @@ -785,12 +785,13 @@ A size of \"unlimited\" means unlimited lines. The default is 10."), set_record_call_history_size, NULL, &set_record_cmdlist, &show_record_cmdlist); - c = add_prefix_cmd ("record", class_obscure, cmd_record_start, + cmd_list_element *record_cmd + = add_prefix_cmd ("record", class_obscure, cmd_record_start, _("Start recording."), &record_cmdlist, 0, &cmdlist); - set_cmd_completer (c, filename_completer); + set_cmd_completer (record_cmd, filename_completer); - add_com_alias ("rec", "record", class_obscure, 1); + add_com_alias ("rec", record_cmd, class_obscure, 1); add_basic_prefix_cmd ("record", class_support, _("Set record options."), &set_record_cmdlist, 0, &setlist); diff --git a/gdb/regcache.c b/gdb/regcache.c index 51e9eff..2d50f3e 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -2092,10 +2092,11 @@ _initialize_regcache () gdb::observers::thread_ptid_changed.attach (regcache_thread_ptid_changed, "regcache"); - add_cmd ("register-cache", class_maintenance, reg_flush_command, - _("Force gdb to flush its register and frame cache."), - &maintenanceflushlist); - c = add_com_alias ("flushregs", "maintenance flush register-cache", + cmd_list_element *maintenance_flush_register_cache_cmd + = add_cmd ("register-cache", class_maintenance, reg_flush_command, + _("Force gdb to flush its register and frame cache."), + &maintenanceflushlist); + c = add_com_alias ("flushregs", maintenance_flush_register_cache_cmd, class_maintenance, 0); deprecate_cmd (c, "maintenance flush register-cache"); diff --git a/gdb/reverse.c b/gdb/reverse.c index e51defb..feca1b6 100644 --- a/gdb/reverse.c +++ b/gdb/reverse.c @@ -326,38 +326,39 @@ void _initialize_reverse (); void _initialize_reverse () { - add_com ("reverse-step", class_run, reverse_step, _("\ + cmd_list_element *reverse_step_cmd + = add_com ("reverse-step", class_run, reverse_step, _("\ Step program backward until it reaches the beginning of another source line.\n\ -Argument N means do this N times (or till program stops for another reason).") - ); - add_com_alias ("rs", "reverse-step", class_run, 1); +Argument N means do this N times (or till program stops for another reason).")); + add_com_alias ("rs", reverse_step_cmd, class_run, 1); - add_com ("reverse-next", class_run, reverse_next, _("\ + cmd_list_element *reverse_next_cmd + = add_com ("reverse-next", class_run, reverse_next, _("\ Step program backward, proceeding through subroutine calls.\n\ Like the \"reverse-step\" command as long as subroutine calls do not happen;\n\ when they do, the call is treated as one instruction.\n\ -Argument N means do this N times (or till program stops for another reason).") - ); - add_com_alias ("rn", "reverse-next", class_run, 1); +Argument N means do this N times (or till program stops for another reason).")); + add_com_alias ("rn", reverse_next_cmd, class_run, 1); - add_com ("reverse-stepi", class_run, reverse_stepi, _("\ + cmd_list_element *reverse_stepi_cmd + = add_com ("reverse-stepi", class_run, reverse_stepi, _("\ Step backward exactly one instruction.\n\ -Argument N means do this N times (or till program stops for another reason).") - ); - add_com_alias ("rsi", "reverse-stepi", class_run, 0); +Argument N means do this N times (or till program stops for another reason).")); + add_com_alias ("rsi", reverse_stepi_cmd, class_run, 0); - add_com ("reverse-nexti", class_run, reverse_nexti, _("\ + cmd_list_element *reverse_nexti_cmd + = add_com ("reverse-nexti", class_run, reverse_nexti, _("\ Step backward one instruction, but proceed through called subroutines.\n\ -Argument N means do this N times (or till program stops for another reason).") - ); - add_com_alias ("rni", "reverse-nexti", class_run, 0); +Argument N means do this N times (or till program stops for another reason).")); + add_com_alias ("rni", reverse_nexti_cmd, class_run, 0); - add_com ("reverse-continue", class_run, reverse_continue, _("\ + cmd_list_element *reverse_continue_cmd + = add_com ("reverse-continue", class_run, reverse_continue, _("\ Continue program being debugged but run it in reverse.\n\ If proceeding from breakpoint, a number N may be used as an argument,\n\ which means to set the ignore count of that breakpoint to N - 1 (so that\n\ the breakpoint won't break until the Nth time it is reached).")); - add_com_alias ("rc", "reverse-continue", class_run, 0); + add_com_alias ("rc", reverse_continue_cmd, class_run, 0); add_com ("reverse-finish", class_run, reverse_finish, _("\ Execute backward until just before selected stack frame is called.")); diff --git a/gdb/source.c b/gdb/source.c index 54cb45f..94e61cc 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -1904,8 +1904,6 @@ void _initialize_source (); void _initialize_source () { - struct cmd_list_element *c; - init_source_path (); /* The intention is to use POSIX Basic Regular Expressions. @@ -1914,7 +1912,8 @@ _initialize_source () just an approximation. */ re_set_syntax (RE_SYNTAX_GREP); - c = add_cmd ("directory", class_files, directory_command, _("\ + cmd_list_element *directory_cmd + = add_cmd ("directory", class_files, directory_command, _("\ Add directory DIR to beginning of search path for source files.\n\ Forget cached info on source file locations and line positions.\n\ DIR can also be $cwd for the current working directory, or $cdir for the\n\ @@ -1923,9 +1922,9 @@ With no argument, reset the search path to $cdir:$cwd, the default."), &cmdlist); if (dbx_commands) - add_com_alias ("use", "directory", class_files, 0); + add_com_alias ("use", directory_cmd, class_files, 0); - set_cmd_completer (c, filename_completer); + set_cmd_completer (directory_cmd, filename_completer); add_setshow_optional_filename_cmd ("directories", class_files, @@ -1959,16 +1958,18 @@ This sets the default address for \"x\" to the line's first instruction\n\ so that \"x/i\" suffices to start examining the machine code.\n\ The address is also stored as the value of \"$_\".")); - add_com ("forward-search", class_files, forward_search_command, _("\ + cmd_list_element *forward_search_cmd + = add_com ("forward-search", class_files, forward_search_command, _("\ Search for regular expression (see regex(3)) from last line listed.\n\ The matching line number is also stored as the value of \"$_\".")); - add_com_alias ("search", "forward-search", class_files, 0); - add_com_alias ("fo", "forward-search", class_files, 1); + add_com_alias ("search", forward_search_cmd, class_files, 0); + add_com_alias ("fo", forward_search_cmd, class_files, 1); - add_com ("reverse-search", class_files, reverse_search_command, _("\ + cmd_list_element *reverse_search_cmd + = add_com ("reverse-search", class_files, reverse_search_command, _("\ Search backward for regular expression (see regex(3)) from last line listed.\n\ The matching line number is also stored as the value of \"$_\".")); - add_com_alias ("rev", "reverse-search", class_files, 1); + add_com_alias ("rev", reverse_search_cmd, class_files, 1); add_setshow_integer_cmd ("listsize", class_support, &lines_to_list, _("\ Set number of source lines gdb will list by default."), _("\ diff --git a/gdb/stack.c b/gdb/stack.c index 334d974..a3a6ba6 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -3329,22 +3329,24 @@ An argument says how many frames up to go.")); Same as the `up' command, but does not print anything.\n\ This is useful in command scripts.")); - add_com ("down", class_stack, down_command, _("\ + cmd_list_element *down_cmd + = add_com ("down", class_stack, down_command, _("\ Select and print stack frame called by this one.\n\ An argument says how many frames down to go.")); - add_com_alias ("do", "down", class_stack, 1); - add_com_alias ("dow", "down", class_stack, 1); + add_com_alias ("do", down_cmd, class_stack, 1); + add_com_alias ("dow", down_cmd, class_stack, 1); add_com ("down-silently", class_support, down_silently_command, _("\ Same as the `down' command, but does not print anything.\n\ This is useful in command scripts.")); - add_prefix_cmd ("frame", class_stack, - &frame_cmd.base_command, _("\ + cmd_list_element *frame_cmd_el + = add_prefix_cmd ("frame", class_stack, + &frame_cmd.base_command, _("\ Select and print a stack frame.\n\ With no argument, print the selected stack frame. (See also \"info frame\").\n\ A single numerical argument specifies the frame to select."), - &frame_cmd_list, 1, &cmdlist); - add_com_alias ("f", "frame", class_stack, 1); + &frame_cmd_list, 1, &cmdlist); + add_com_alias ("f", frame_cmd_el, class_stack, 1); #define FRAME_APPLY_OPTION_HELP "\ Prints the frame location information followed by COMMAND output.\n\ @@ -3498,14 +3500,14 @@ For backward compatibility, the following qualifiers are supported:\n\ With a negative COUNT, print outermost -COUNT frames."), backtrace_opts); - cmd_list_element *c = add_com ("backtrace", class_stack, - backtrace_command, - backtrace_help.c_str ()); - set_cmd_completer_handle_brkchars (c, backtrace_command_completer); + cmd_list_element *backtrace_cmd + = add_com ("backtrace", class_stack, backtrace_command, + backtrace_help.c_str ()); + set_cmd_completer_handle_brkchars (backtrace_cmd, backtrace_command_completer); - add_com_alias ("bt", "backtrace", class_stack, 0); + add_com_alias ("bt", backtrace_cmd, class_stack, 0); - add_com_alias ("where", "backtrace", class_stack, 0); + add_com_alias ("where", backtrace_cmd, class_stack, 0); add_info ("stack", backtrace_command, _("Backtrace of the stack, or innermost COUNT frames.")); add_info_alias ("s", "stack", 1); diff --git a/gdb/symfile.c b/gdb/symfile.c index 4ba6953..b2034c6 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -3863,12 +3863,13 @@ When OFFSET is provided, FILE must also be provided. FILE can be provided\n\ on its own."), &cmdlist); set_cmd_completer (c, filename_completer); - add_basic_prefix_cmd ("overlay", class_support, - _("Commands for debugging overlays."), &overlaylist, - 0, &cmdlist); + cmd_list_element *overlay_cmd + = add_basic_prefix_cmd ("overlay", class_support, + _("Commands for debugging overlays."), &overlaylist, + 0, &cmdlist); - add_com_alias ("ovly", "overlay", class_support, 1); - add_com_alias ("ov", "overlay", class_support, 1); + add_com_alias ("ovly", overlay_cmd, class_support, 1); + add_com_alias ("ov", overlay_cmd, class_support, 1); add_cmd ("map-overlay", class_support, map_overlay_command, _("Assert that an overlay section is mapped."), &overlaylist); diff --git a/gdb/thread.c b/gdb/thread.c index 4005101..f850f05 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -2133,10 +2133,13 @@ Options:\n\ c = add_info ("threads", info_threads_command, info_threads_help.c_str ()); set_cmd_completer_handle_brkchars (c, info_threads_command_completer); - add_prefix_cmd ("thread", class_run, thread_command, _("\ + cmd_list_element *thread_cmd + = add_prefix_cmd ("thread", class_run, thread_command, _("\ Use this command to switch between threads.\n\ The new thread ID must be currently known."), - &thread_cmd_list, 1, &cmdlist); + &thread_cmd_list, 1, &cmdlist); + + add_com_alias ("t", thread_cmd, class_run, 1); #define THREAD_APPLY_OPTION_HELP "\ Prints per-inferior thread number and target system's thread id\n\ @@ -2203,8 +2206,6 @@ Usage: thread find REGEXP\n\ Will display thread ids whose name, target ID, or extra info matches REGEXP."), &thread_cmd_list); - add_com_alias ("t", "thread", class_run, 1); - add_setshow_boolean_cmd ("thread-events", no_class, &print_thread_events, _("\ Set printing of thread events (such as thread start and exit)."), _("\ diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index da0e976..abbd507 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -4116,8 +4116,8 @@ one or more \"collect\" commands, to specify what to collect\n\ while single-stepping.\n\n\ Note: this command can only be used in a tracepoint \"actions\" list.")); - add_com_alias ("ws", "while-stepping", class_trace, 0); - add_com_alias ("stepping", "while-stepping", class_trace, 0); + add_com_alias ("ws", while_stepping_cmd_element, class_trace, 0); + add_com_alias ("stepping", while_stepping_cmd_element, class_trace, 0); add_com ("collect", class_trace, collect_pseudocommand, _("\ Specify one or more data items to be collected at a tracepoint.\n\ diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index f036127..4e75a66 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -990,7 +990,6 @@ _initialize_tui_win () { static struct cmd_list_element *tui_setlist; static struct cmd_list_element *tui_showlist; - struct cmd_list_element *cmd; /* Define the classes of commands. They will appear in the help list in the reverse of this order. */ @@ -1004,26 +1003,29 @@ _initialize_tui_win () add_com ("refresh", class_tui, tui_refresh_all_command, _("Refresh the terminal display.")); - cmd = add_com ("tabset", class_tui, tui_set_tab_width_command, _("\ + cmd_list_element *tabset_cmd + = add_com ("tabset", class_tui, tui_set_tab_width_command, _("\ Set the width (in characters) of tab stops.\n\ Usage: tabset N")); - deprecate_cmd (cmd, "set tui tab-width"); + deprecate_cmd (tabset_cmd, "set tui tab-width"); - cmd = add_com ("winheight", class_tui, tui_set_win_height_command, _("\ + cmd_list_element *winheight_cmd + = add_com ("winheight", class_tui, tui_set_win_height_command, _("\ Set or modify the height of a specified window.\n\ Usage: winheight WINDOW-NAME [+ | -] NUM-LINES\n\ Use \"info win\" to see the names of the windows currently being displayed.")); - add_com_alias ("wh", "winheight", class_tui, 0); - set_cmd_completer (cmd, winheight_completer); + add_com_alias ("wh", winheight_cmd, class_tui, 0); + set_cmd_completer (winheight_cmd, winheight_completer); add_info ("win", tui_all_windows_info, _("List of all displayed windows.\n\ Usage: info win")); - cmd = add_com ("focus", class_tui, tui_set_focus_command, _("\ + cmd_list_element *focus_cmd + = add_com ("focus", class_tui, tui_set_focus_command, _("\ Set focus to named window or next/prev window.\n\ Usage: focus [WINDOW-NAME | next | prev]\n\ Use \"info win\" to see the names of the windows currently being displayed.")); - add_com_alias ("fs", "focus", class_tui, 0); - set_cmd_completer (cmd, focus_completer); + add_com_alias ("fs", focus_cmd, class_tui, 0); + set_cmd_completer (focus_cmd, focus_completer); add_com ("+", class_tui, tui_scroll_forward_command, _("\ Scroll window forward.\n\ Usage: + [N] [WIN]\n\ |