From 5e84b7eefba5b4299b0ca80aecc5d4e99c195c1e Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 27 May 2021 13:59:01 -0400 Subject: [PATCH] gdb: remove add_alias_cmd overload that accepts a string Same idea as previous patch, but for add_alias_cmd. Remove the overload that accepts the target command as a string (the target command name), leaving only the one that takes the cmd_list_element. gdb/ChangeLog: * command.h (add_alias_cmd): Accept target as cmd_list_element. Update callers. Change-Id: I546311f411e9e7da9302322d6ffad4e6c56df266 --- gdb/ChangeLog | 5 ++++ gdb/arch-utils.c | 16 +++++----- gdb/breakpoint.c | 5 ++-- gdb/cli/cli-cmds.c | 3 +- gdb/cli/cli-decode.c | 12 -------- gdb/command.h | 4 --- gdb/corefile.c | 2 +- gdb/cp-support.c | 12 ++++---- gdb/gnu-nat.c | 54 ++++++++++++++++++++-------------- gdb/guile/guile.c | 20 +++++++------ gdb/language.c | 24 ++++++++------- gdb/macrocmd.c | 15 ++++++---- gdb/maint.c | 10 ++++--- gdb/mips-tdep.c | 25 +++++++++------- gdb/printcmd.c | 7 +++-- gdb/record-btrace.c | 30 ++++++++++--------- gdb/record-full.c | 69 ++++++++++++++++++++++++-------------------- gdb/record.c | 63 +++++++++++++++++++++++----------------- gdb/remote.c | 19 +++++++----- gdb/solib.c | 15 +++++----- gdb/sparc64-tdep.c | 7 +++-- gdb/symtab.c | 11 +++---- gdb/tracepoint.c | 8 ++--- gdb/valprint.c | 24 ++++++++------- gdb/value.c | 5 ++-- gdb/windows-tdep.c | 9 +++--- 26 files changed, 260 insertions(+), 214 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4279359ba33..b52d06012f2 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2021-05-27 Simon Marchi + + * command.h (add_alias_cmd): Accept target as + cmd_list_element. Update callers. + 2021-05-27 Simon Marchi * command.h (add_info_alias): Accept target as diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 5bb9c758449..c75a79757ea 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -757,13 +757,15 @@ initialize_current_architecture (void) arches = XRESIZEVEC (const char *, arches, nr + 2); arches[nr + 0] = "auto"; arches[nr + 1] = NULL; - add_setshow_enum_cmd ("architecture", class_support, - arches, &set_architecture_string, - _("Set architecture of target."), - _("Show architecture of target."), NULL, - set_architecture, show_architecture, - &setlist, &showlist); - add_alias_cmd ("processor", "architecture", class_support, 1, &setlist); + set_show_commands architecture_cmds + = add_setshow_enum_cmd ("architecture", class_support, + arches, &set_architecture_string, + _("Set architecture of target."), + _("Show architecture of target."), NULL, + set_architecture, show_architecture, + &setlist, &showlist); + add_alias_cmd ("processor", architecture_cmds.set, class_support, 1, + &setlist); } } diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index ae05d1802a8..dc00b4c7359 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -16062,12 +16062,13 @@ last tracepoint set.")); add_info_alias ("tp", info_tracepoints_cmd, 1); - add_cmd ("tracepoints", class_trace, delete_trace_command, _("\ + cmd_list_element *delete_tracepoints_cmd + = add_cmd ("tracepoints", class_trace, delete_trace_command, _("\ Delete specified tracepoints.\n\ Arguments are tracepoint numbers, separated by spaces.\n\ No argument means delete all tracepoints."), &deletelist); - add_alias_cmd ("tr", "tracepoints", class_trace, 1, &deletelist); + add_alias_cmd ("tr", delete_tracepoints_cmd, class_trace, 1, &deletelist); c = add_cmd ("tracepoints", class_trace, disable_trace_command, _("\ Disable specified tracepoints.\n\ diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 8b2aa5aad5a..56ae12a0c19 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -1908,8 +1908,7 @@ alias_command (const char *args, int from_tty) /* add_cmd requires *we* allocate space for name, hence the xstrdup. */ alias_cmd = add_alias_cmd (xstrdup (alias_argv[alias_argc - 1]), - command_argv[command_argc - 1], - class_alias, a_opts.abbrev_flag, + target_cmd, class_alias, a_opts.abbrev_flag, c_command->subcommands); } diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 2c2d72e2090..009986c9cb1 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -333,18 +333,6 @@ add_alias_cmd (const char *name, cmd_list_element *target, return c; } -struct cmd_list_element * -add_alias_cmd (const char *name, const char *target_name, - enum command_class theclass, int abbrev_flag, - struct cmd_list_element **list) -{ - const char *tmp = target_name; - cmd_list_element *target = lookup_cmd (&tmp, *list, "", NULL, 1, 1); - - return add_alias_cmd (name, target, theclass, abbrev_flag, list); -} - - /* Update the prefix field of all sub-commands of the prefix command C. We must do this when a prefix command is defined as the GDB init sequence does not guarantee that a prefix command is created before its sub-commands. diff --git a/gdb/command.h b/gdb/command.h index e14f27b5f9a..f8988e41494 100644 --- a/gdb/command.h +++ b/gdb/command.h @@ -174,10 +174,6 @@ extern struct cmd_list_element *add_cmd_suppress_notification struct cmd_list_element **list, int *suppress_notification); -extern struct cmd_list_element *add_alias_cmd (const char *, const char *, - enum command_class, int, - struct cmd_list_element **); - extern struct cmd_list_element *add_alias_cmd (const char *, cmd_list_element *, enum command_class, int, diff --git a/gdb/corefile.c b/gdb/corefile.c index ddaa77272a9..ff2494738b0 100644 --- a/gdb/corefile.c +++ b/gdb/corefile.c @@ -478,7 +478,7 @@ Use `set gnutarget auto' to specify automatic detection."), &setlist, &showlist); set_cmd_completer (set_show_gnutarget.set, complete_set_gnutarget); - add_alias_cmd ("g", "gnutarget", class_files, 1, &setlist); + add_alias_cmd ("g", set_show_gnutarget.set, class_files, 1, &setlist); if (getenv ("GNUTARGET")) set_gnutarget (getenv ("GNUTARGET")); diff --git a/gdb/cp-support.c b/gdb/cp-support.c index e87c9d420e4..5bd8fd4e940 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -2209,12 +2209,12 @@ void _initialize_cp_support (); void _initialize_cp_support () { - add_basic_prefix_cmd ("cplus", class_maintenance, - _("C++ maintenance commands."), - &maint_cplus_cmd_list, - 0, &maintenancelist); - add_alias_cmd ("cp", "cplus", - class_maintenance, 1, + cmd_list_element *maintenance_cplus + = add_basic_prefix_cmd ("cplus", class_maintenance, + _("C++ maintenance commands."), + &maint_cplus_cmd_list, + 0, &maintenancelist); + add_alias_cmd ("cp", maintenance_cplus, class_maintenance, 1, &maintenancelist); add_cmd ("first_component", diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c index aadd3e894ce..67ce00e9c30 100644 --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -3197,25 +3197,31 @@ Show whether new threads are allowed to run (once gdb has noticed them)."), _("Show the default detach-suspend-count value for new threads."), &show_thread_default_cmd_list); - add_cmd ("signals", class_run, set_signals_cmd, _("\ + cmd_list_element *set_signals_cmd + = add_cmd ("signals", class_run, set_signals_cmd, _("\ Set whether the inferior process's signals will be intercepted.\n\ Mach exceptions (such as breakpoint traps) are not affected."), - &setlist); - add_alias_cmd ("sigs", "signals", class_run, 1, &setlist); - add_cmd ("signals", no_class, show_signals_cmd, _("\ + &setlist); + add_alias_cmd ("sigs", set_signals_cmd, class_run, 1, &setlist); + + cmd_list_element *show_signals_cmd + = add_cmd ("signals", no_class, show_signals_cmd, _("\ Show whether the inferior process's signals will be intercepted."), - &showlist); - add_alias_cmd ("sigs", "signals", no_class, 1, &showlist); + &showlist); + add_alias_cmd ("sigs", show_signals_cmd, no_class, 1, &showlist); - add_cmd ("signal-thread", class_run, set_sig_thread_cmd, _("\ + cmd_list_element *set_signal_thread_cmd + = add_cmd ("signal-thread", class_run, set_sig_thread_cmd, _("\ Set the thread that gdb thinks is the libc signal thread.\n\ This thread is run when delivering a signal to a non-stopped process."), - &setlist); - add_alias_cmd ("sigthread", "signal-thread", class_run, 1, &setlist); - add_cmd ("signal-thread", no_class, show_sig_thread_cmd, _("\ + &setlist); + add_alias_cmd ("sigthread", set_signal_thread_cmd, class_run, 1, &setlist); + + cmd_list_element *show_signal_thread_cmd + = add_cmd ("signal-thread", no_class, show_sig_thread_cmd, _("\ Set the thread that gdb thinks is the libc signal thread."), - &showlist); - add_alias_cmd ("sigthread", "signal-thread", no_class, 1, &showlist); + &showlist); + add_alias_cmd ("sigthread", show_signal_thread_cmd, no_class, 1, &showlist); add_cmd ("stopped", class_run, set_stopped_cmd, _("\ Set whether gdb thinks the inferior process is stopped as with SIGSTOP.\n\ @@ -3225,13 +3231,14 @@ Stopped process will be continued by sending them a signal."), Show whether gdb thinks the inferior process is stopped as with SIGSTOP."), &showlist); - add_cmd ("exceptions", class_run, set_exceptions_cmd, _("\ + cmd_list_element *set_exceptions_cmd + = add_cmd ("exceptions", class_run, set_exceptions_cmd, _("\ Set whether exceptions in the inferior process will be trapped.\n\ When exceptions are turned off, neither breakpoints nor single-stepping\n\ -will work."), - &setlist); +will work."), &setlist); /* Allow `set exc' despite conflict with `set exception-port'. */ - add_alias_cmd ("exc", "exceptions", class_run, 1, &setlist); + add_alias_cmd ("exc", set_exceptions_cmd, class_run, 1, &setlist); + add_cmd ("exceptions", no_class, show_exceptions_cmd, _("\ Show whether exceptions in the inferior process will be trapped."), &showlist); @@ -3262,12 +3269,14 @@ used to pause individual threads by default instead."), "on the thread when detaching."), &show_task_cmd_list); - add_cmd ("exception-port", no_class, set_task_exc_port_cmd, _("\ + cmd_list_element *set_task_exception_port_cmd + = add_cmd ("exception-port", no_class, set_task_exc_port_cmd, _("\ Set the task exception port to which we forward exceptions.\n\ The argument should be the value of the send right in the task."), - &set_task_cmd_list); - add_alias_cmd ("excp", "exception-port", no_class, 1, &set_task_cmd_list); - add_alias_cmd ("exc-port", "exception-port", no_class, 1, + &set_task_cmd_list); + add_alias_cmd ("excp", set_task_exception_port_cmd, no_class, 1, + &set_task_cmd_list); + add_alias_cmd ("exc-port", set_task_exception_port_cmd, no_class, 1, &set_task_cmd_list); /* A convenient way of turning on all options require to noninvasively @@ -3458,8 +3467,9 @@ Set the thread exception port to which we forward exceptions.\n\ This overrides the task exception port.\n\ The argument should be the value of the send right in the task."), &set_thread_cmd_list); - add_alias_cmd ("excp", "exception-port", no_class, 1, &set_thread_cmd_list); - add_alias_cmd ("exc-port", "exception-port", no_class, 1, + add_alias_cmd ("excp", set_thread_exception_port_cmd, no_class, 1, + &set_thread_cmd_list); + add_alias_cmd ("exc-port", set_thread_exception_port_cmd, no_class, 1, &set_thread_cmd_list); add_cmd ("takeover-suspend-count", no_class, thread_takeover_sc_cmd, _("\ diff --git a/gdb/guile/guile.c b/gdb/guile/guile.c index 3b1fca3d20c..a28dee37ed8 100644 --- a/gdb/guile/guile.c +++ b/gdb/guile/guile.c @@ -780,15 +780,17 @@ This command is only a placeholder.") ); add_com_alias ("gu", guile_cmd_element, class_obscure, 1); - add_basic_prefix_cmd ("guile", class_obscure, - _("Prefix command for Guile preference settings."), - &set_guile_list, 0, &setlist); - add_alias_cmd ("gu", "guile", class_obscure, 1, &setlist); - - add_show_prefix_cmd ("guile", class_obscure, - _("Prefix command for Guile preference settings."), - &show_guile_list, 0, &showlist); - add_alias_cmd ("gu", "guile", class_obscure, 1, &showlist); + cmd_list_element *set_guile_cmd + = add_basic_prefix_cmd ("guile", class_obscure, + _("Prefix command for Guile preference settings."), + &set_guile_list, 0, &setlist); + add_alias_cmd ("gu", set_guile_cmd, class_obscure, 1, &setlist); + + cmd_list_element *show_guile_cmd + = add_show_prefix_cmd ("guile", class_obscure, + _("Prefix command for Guile preference settings."), + &show_guile_list, 0, &showlist); + add_alias_cmd ("gu", show_guile_cmd, class_obscure, 1, &showlist); cmd_list_element *info_guile_cmd = add_basic_prefix_cmd ("guile", class_obscure, diff --git a/gdb/language.c b/gdb/language.c index a3f96ecd6ff..0d1e3848de8 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -1164,17 +1164,19 @@ _initialize_language () /* GDB commands for language specific stuff. */ - add_basic_prefix_cmd ("check", no_class, - _("Set the status of the type/range checker."), - &setchecklist, 0, &setlist); - add_alias_cmd ("c", "check", no_class, 1, &setlist); - add_alias_cmd ("ch", "check", no_class, 1, &setlist); - - add_show_prefix_cmd ("check", no_class, - _("Show the status of the type/range checker."), - &showchecklist, 0, &showlist); - add_alias_cmd ("c", "check", no_class, 1, &showlist); - add_alias_cmd ("ch", "check", no_class, 1, &showlist); + cmd_list_element *set_check_cmd + = add_basic_prefix_cmd ("check", no_class, + _("Set the status of the type/range checker."), + &setchecklist, 0, &setlist); + add_alias_cmd ("c", set_check_cmd, no_class, 1, &setlist); + add_alias_cmd ("ch", set_check_cmd, no_class, 1, &setlist); + + cmd_list_element *show_check_cmd + = add_show_prefix_cmd ("check", no_class, + _("Show the status of the type/range checker."), + &showchecklist, 0, &showlist); + add_alias_cmd ("c", show_check_cmd, no_class, 1, &showlist); + add_alias_cmd ("ch", show_check_cmd, no_class, 1, &showlist); add_setshow_enum_cmd ("range", class_support, type_or_range_names, &range, diff --git a/gdb/macrocmd.c b/gdb/macrocmd.c index 4e4a68d5c1d..28a57f7bac9 100644 --- a/gdb/macrocmd.c +++ b/gdb/macrocmd.c @@ -457,12 +457,15 @@ _initialize_macrocmd () _("Prefix for commands dealing with C preprocessor macros."), ¯olist, 0, &cmdlist); - add_cmd ("expand", no_class, macro_expand_command, _("\ + cmd_list_element *macro_expand_cmd + = add_cmd ("expand", no_class, macro_expand_command, _("\ Fully expand any C/C++ preprocessor macro invocations in EXPRESSION.\n\ Show the expanded expression."), - ¯olist); - add_alias_cmd ("exp", "expand", no_class, 1, ¯olist); - add_cmd ("expand-once", no_class, macro_expand_once_command, _("\ + ¯olist); + add_alias_cmd ("exp", macro_expand_cmd, no_class, 1, ¯olist); + + cmd_list_element *macro_expand_once_cmd + = add_cmd ("expand-once", no_class, macro_expand_once_command, _("\ Expand C/C++ preprocessor macro invocations appearing directly in EXPRESSION.\n\ Show the expanded expression.\n\ \n\ @@ -473,8 +476,8 @@ introduces further macro invocations, those are left unexpanded.\n\ `macro expand-once' helps you see how a particular macro expands,\n\ whereas `macro expand' shows you how all the macros involved in an\n\ expression work together to yield a pre-processed expression."), - ¯olist); - add_alias_cmd ("exp1", "expand-once", no_class, 1, ¯olist); + ¯olist); + add_alias_cmd ("exp1", macro_expand_once_cmd, no_class, 1, ¯olist); add_info ("macro", info_macro_command, _("Show the definition of MACRO, and it's source location.\n\ diff --git a/gdb/maint.c b/gdb/maint.c index 91a7f77d0eb..26bacbfeb76 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -1143,11 +1143,13 @@ a human readable form, to cause GDB to deliberately dump core, etc."), add_com_alias ("mt", maintenance_cmd, class_maintenance, 1); - add_basic_prefix_cmd ("info", class_maintenance, _("\ + cmd_list_element *maintenance_info_cmd + = add_basic_prefix_cmd ("info", class_maintenance, _("\ Commands for showing internal info about the program being debugged."), - &maintenanceinfolist, 0, - &maintenancelist); - add_alias_cmd ("i", "info", class_maintenance, 1, &maintenancelist); + &maintenanceinfolist, 0, + &maintenancelist); + add_alias_cmd ("i", maintenance_info_cmd, class_maintenance, 1, + &maintenancelist); const auto opts = make_maint_info_sections_options_def_group (nullptr); static std::string maint_info_sections_command_help diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 2fe83324738..31cac9384e9 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -8994,17 +8994,20 @@ and is updated automatically from ELF file flags if available."), add_cmd ("single", class_support, set_mipsfpu_single_command, _("Select single-precision MIPS floating-point coprocessor."), &mipsfpulist); - add_cmd ("double", class_support, set_mipsfpu_double_command, - _("Select double-precision MIPS floating-point coprocessor."), - &mipsfpulist); - add_alias_cmd ("on", "double", class_support, 1, &mipsfpulist); - add_alias_cmd ("yes", "double", class_support, 1, &mipsfpulist); - add_alias_cmd ("1", "double", class_support, 1, &mipsfpulist); - add_cmd ("none", class_support, set_mipsfpu_none_command, - _("Select no MIPS floating-point coprocessor."), &mipsfpulist); - add_alias_cmd ("off", "none", class_support, 1, &mipsfpulist); - add_alias_cmd ("no", "none", class_support, 1, &mipsfpulist); - add_alias_cmd ("0", "none", class_support, 1, &mipsfpulist); + cmd_list_element *set_mipsfpu_double_cmd + = add_cmd ("double", class_support, set_mipsfpu_double_command, + _("Select double-precision MIPS floating-point coprocessor."), + &mipsfpulist); + add_alias_cmd ("on", set_mipsfpu_double_cmd, class_support, 1, &mipsfpulist); + add_alias_cmd ("yes", set_mipsfpu_double_cmd, class_support, 1, &mipsfpulist); + add_alias_cmd ("1", set_mipsfpu_double_cmd, class_support, 1, &mipsfpulist); + + cmd_list_element *set_mipsfpu_none_cmd + = add_cmd ("none", class_support, set_mipsfpu_none_command, + _("Select no MIPS floating-point coprocessor."), &mipsfpulist); + add_alias_cmd ("off", set_mipsfpu_none_cmd, class_support, 1, &mipsfpulist); + add_alias_cmd ("no", set_mipsfpu_none_cmd, class_support, 1, &mipsfpulist); + add_alias_cmd ("0", set_mipsfpu_none_cmd, class_support, 1, &mipsfpulist); add_cmd ("auto", class_support, set_mipsfpu_auto_command, _("Select MIPS floating-point coprocessor automatically."), &mipsfpulist); diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 8daa87cf978..7eba2993fb2 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -3304,7 +3304,8 @@ current working language. The result is printed and saved in the value\n\ history, if it is not void.")); set_cmd_completer_handle_brkchars (c, print_command_completer); - add_cmd ("variable", class_vars, set_command, _("\ + cmd_list_element *set_variable_cmd + = add_cmd ("variable", class_vars, set_command, _("\ Evaluate expression EXP and assign result to variable VAR.\n\ Usage: set variable VAR = EXP\n\ This uses assignment syntax appropriate for the current language\n\ @@ -3313,8 +3314,8 @@ VAR may be a debugger \"convenience\" variable (names starting\n\ with $), a register (a few standard names starting with $), or an actual\n\ variable in the program being debugged. EXP is any valid expression.\n\ This may usually be abbreviated to simply \"set\"."), - &setlist); - add_alias_cmd ("var", "variable", class_vars, 0, &setlist); + &setlist); + add_alias_cmd ("var", set_variable_cmd, class_vars, 0, &setlist); const auto print_opts = make_value_print_options_def_group (nullptr); diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index c04e1cde721..00affb85d22 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -3109,25 +3109,29 @@ void _initialize_record_btrace (); void _initialize_record_btrace () { - add_prefix_cmd ("btrace", class_obscure, cmd_record_btrace_start, - _("Start branch trace recording."), &record_btrace_cmdlist, - 0, &record_cmdlist); - add_alias_cmd ("b", "btrace", class_obscure, 1, &record_cmdlist); - - add_cmd ("bts", class_obscure, cmd_record_btrace_bts_start, - _("\ + cmd_list_element *record_btrace_cmd + = add_prefix_cmd ("btrace", class_obscure, cmd_record_btrace_start, + _("Start branch trace recording."), + &record_btrace_cmdlist, 0, &record_cmdlist); + add_alias_cmd ("b", record_btrace_cmd, class_obscure, 1, &record_cmdlist); + + cmd_list_element *record_btrace_bts_cmd + = add_cmd ("bts", class_obscure, cmd_record_btrace_bts_start, + _("\ Start branch trace recording in Branch Trace Store (BTS) format.\n\n\ The processor stores a from/to record for each branch into a cyclic buffer.\n\ This format may not be available on all processors."), - &record_btrace_cmdlist); - add_alias_cmd ("bts", "btrace bts", class_obscure, 1, &record_cmdlist); + &record_btrace_cmdlist); + add_alias_cmd ("bts", record_btrace_bts_cmd, class_obscure, 1, + &record_cmdlist); - add_cmd ("pt", class_obscure, cmd_record_btrace_pt_start, - _("\ + cmd_list_element *record_btrace_pt_cmd + = add_cmd ("pt", class_obscure, cmd_record_btrace_pt_start, + _("\ Start branch trace recording in Intel Processor Trace format.\n\n\ This format may not be available on all processors."), - &record_btrace_cmdlist); - add_alias_cmd ("pt", "btrace pt", class_obscure, 1, &record_cmdlist); + &record_btrace_cmdlist); + add_alias_cmd ("pt", record_btrace_pt_cmd, class_obscure, 1, &record_cmdlist); add_basic_prefix_cmd ("btrace", class_support, _("Set record options."), &set_record_btrace_cmdlist, diff --git a/gdb/record-full.c b/gdb/record-full.c index 91da1076194..03e39eeaf3a 100644 --- a/gdb/record-full.c +++ b/gdb/record-full.c @@ -2796,14 +2796,15 @@ _initialize_record_full () _("Start full execution recording."), &record_full_cmdlist, 0, &record_cmdlist); - c = add_cmd ("restore", class_obscure, cmd_record_full_restore, + cmd_list_element *record_full_restore_cmd + = add_cmd ("restore", class_obscure, cmd_record_full_restore, _("Restore the execution log from a file.\n\ Argument is filename. File must be created with 'record save'."), &record_full_cmdlist); - set_cmd_completer (c, filename_completer); + set_cmd_completer (record_full_restore_cmd, filename_completer); /* Deprecate the old version without "full" prefix. */ - c = add_alias_cmd ("restore", "full restore", class_obscure, 1, + c = add_alias_cmd ("restore", record_full_restore_cmd, class_obscure, 1, &record_cmdlist); set_cmd_completer (c, filename_completer); deprecate_cmd (c, "record full restore"); @@ -2817,61 +2818,67 @@ Argument is filename. File must be created with 'record save'."), 0, &show_record_cmdlist); /* Record instructions number limit command. */ - add_setshow_boolean_cmd ("stop-at-limit", no_class, - &record_full_stop_at_limit, _("\ + set_show_commands set_record_full_stop_at_limit_cmds + = add_setshow_boolean_cmd ("stop-at-limit", no_class, + &record_full_stop_at_limit, _("\ Set whether record/replay stops when record/replay buffer becomes full."), _("\ Show whether record/replay stops when record/replay buffer becomes full."), _("Default is ON.\n\ When ON, if the record/replay buffer becomes full, ask user what to do.\n\ When OFF, if the record/replay buffer becomes full,\n\ delete the oldest recorded instruction to make room for each new one."), - NULL, NULL, - &set_record_full_cmdlist, &show_record_full_cmdlist); + NULL, NULL, + &set_record_full_cmdlist, + &show_record_full_cmdlist); - c = add_alias_cmd ("stop-at-limit", "full stop-at-limit", no_class, 1, + c = add_alias_cmd ("stop-at-limit", + set_record_full_stop_at_limit_cmds.set, no_class, 1, &set_record_cmdlist); deprecate_cmd (c, "set record full stop-at-limit"); - c = add_alias_cmd ("stop-at-limit", "full stop-at-limit", no_class, 1, + c = add_alias_cmd ("stop-at-limit", + set_record_full_stop_at_limit_cmds.show, no_class, 1, &show_record_cmdlist); deprecate_cmd (c, "show record full stop-at-limit"); - add_setshow_uinteger_cmd ("insn-number-max", no_class, - &record_full_insn_max_num, - _("Set record/replay buffer limit."), - _("Show record/replay buffer limit."), _("\ + set_show_commands record_full_insn_number_max_cmds + = add_setshow_uinteger_cmd ("insn-number-max", no_class, + &record_full_insn_max_num, + _("Set record/replay buffer limit."), + _("Show record/replay buffer limit."), _("\ Set the maximum number of instructions to be stored in the\n\ record/replay buffer. A value of either \"unlimited\" or zero means no\n\ limit. Default is 200000."), - set_record_full_insn_max_num, - NULL, &set_record_full_cmdlist, - &show_record_full_cmdlist); + set_record_full_insn_max_num, + NULL, &set_record_full_cmdlist, + &show_record_full_cmdlist); - c = add_alias_cmd ("insn-number-max", "full insn-number-max", no_class, 1, - &set_record_cmdlist); + c = add_alias_cmd ("insn-number-max", record_full_insn_number_max_cmds.set, + no_class, 1, &set_record_cmdlist); deprecate_cmd (c, "set record full insn-number-max"); - c = add_alias_cmd ("insn-number-max", "full insn-number-max", no_class, 1, - &show_record_cmdlist); + c = add_alias_cmd ("insn-number-max", record_full_insn_number_max_cmds.show, + no_class, 1, &show_record_cmdlist); deprecate_cmd (c, "show record full insn-number-max"); - add_setshow_boolean_cmd ("memory-query", no_class, - &record_full_memory_query, _("\ + set_show_commands record_full_memory_query_cmds + = add_setshow_boolean_cmd ("memory-query", no_class, + &record_full_memory_query, _("\ Set whether query if PREC cannot record memory change of next instruction."), - _("\ + _("\ Show whether query if PREC cannot record memory change of next instruction."), - _("\ + _("\ Default is OFF.\n\ When ON, query if PREC cannot record memory change of next instruction."), - NULL, NULL, - &set_record_full_cmdlist, - &show_record_full_cmdlist); + NULL, NULL, + &set_record_full_cmdlist, + &show_record_full_cmdlist); - c = add_alias_cmd ("memory-query", "full memory-query", no_class, 1, - &set_record_cmdlist); + c = add_alias_cmd ("memory-query", record_full_memory_query_cmds.set, + no_class, 1, &set_record_cmdlist); deprecate_cmd (c, "set record full memory-query"); - c = add_alias_cmd ("memory-query", "full memory-query", no_class, 1, - &show_record_cmdlist); + c = add_alias_cmd ("memory-query", record_full_memory_query_cmds.show, + no_class, 1,&show_record_cmdlist); deprecate_cmd (c, "show record full memory-query"); } diff --git a/gdb/record.c b/gdb/record.c index a09137b34fe..6968c30d930 100644 --- a/gdb/record.c +++ b/gdb/record.c @@ -792,18 +792,24 @@ A size of \"unlimited\" means unlimited lines. The default is 10."), set_cmd_completer (record_cmd, filename_completer); add_com_alias ("rec", record_cmd, class_obscure, 1); - add_basic_prefix_cmd ("record", class_support, - _("Set record options."), &set_record_cmdlist, - 0, &setlist); - add_alias_cmd ("rec", "record", class_obscure, 1, &setlist); - add_show_prefix_cmd ("record", class_support, - _("Show record options."), &show_record_cmdlist, - 0, &showlist); - add_alias_cmd ("rec", "record", class_obscure, 1, &showlist); - add_prefix_cmd ("record", class_support, info_record_command, - _("Info record options."), &info_record_cmdlist, - 0, &infolist); - add_alias_cmd ("rec", "record", class_obscure, 1, &infolist); + + cmd_list_element *set_record_cmd + = add_basic_prefix_cmd ("record", class_support, + _("Set record options."), &set_record_cmdlist, + 0, &setlist); + add_alias_cmd ("rec", set_record_cmd, class_obscure, 1, &setlist); + + cmd_list_element *show_record_cmd + = add_show_prefix_cmd ("record", class_support, + _("Show record options."), &show_record_cmdlist, + 0, &showlist); + add_alias_cmd ("rec", show_record_cmd, class_obscure, 1, &showlist); + + cmd_list_element *info_record_cmd + = add_prefix_cmd ("record", class_support, info_record_command, + _("Info record options."), &info_record_cmdlist, + 0, &infolist); + add_alias_cmd ("rec", info_record_cmd, class_obscure, 1, &infolist); c = add_cmd ("save", class_obscure, cmd_record_save, _("Save the execution log to a file.\n\ @@ -812,26 +818,31 @@ Default filename is 'gdb_record.PROCESS_ID'."), &record_cmdlist); set_cmd_completer (c, filename_completer); - add_cmd ("delete", class_obscure, cmd_record_delete, - _("Delete the rest of execution log and start recording it anew."), - &record_cmdlist); - add_alias_cmd ("d", "delete", class_obscure, 1, &record_cmdlist); - add_alias_cmd ("del", "delete", class_obscure, 1, &record_cmdlist); - - add_cmd ("stop", class_obscure, cmd_record_stop, - _("Stop the record/replay target."), - &record_cmdlist); - add_alias_cmd ("s", "stop", class_obscure, 1, &record_cmdlist); + cmd_list_element *record_delete_cmd + = add_cmd ("delete", class_obscure, cmd_record_delete, + _("Delete the rest of execution log and start recording it \ +anew."), + &record_cmdlist); + add_alias_cmd ("d", record_delete_cmd, class_obscure, 1, &record_cmdlist); + add_alias_cmd ("del", record_delete_cmd, class_obscure, 1, &record_cmdlist); + + cmd_list_element *record_stop_cmd + = add_cmd ("stop", class_obscure, cmd_record_stop, + _("Stop the record/replay target."), + &record_cmdlist); + add_alias_cmd ("s", record_stop_cmd, class_obscure, 1, &record_cmdlist); add_prefix_cmd ("goto", class_obscure, cmd_record_goto, _("\ Restore the program to its state at instruction number N.\n\ Argument is instruction number, as shown by 'info record'."), &record_goto_cmdlist, 1, &record_cmdlist); - add_cmd ("begin", class_obscure, cmd_record_goto_begin, - _("Go to the beginning of the execution log."), - &record_goto_cmdlist); - add_alias_cmd ("start", "begin", class_obscure, 1, &record_goto_cmdlist); + cmd_list_element *record_goto_begin_cmd + = add_cmd ("begin", class_obscure, cmd_record_goto_begin, + _("Go to the beginning of the execution log."), + &record_goto_cmdlist); + add_alias_cmd ("start", record_goto_begin_cmd, class_obscure, 1, + &record_goto_cmdlist); add_cmd ("end", class_obscure, cmd_record_goto_end, _("Go to the end of the execution log."), diff --git a/gdb/remote.c b/gdb/remote.c index f2cb35116c8..8379f514738 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -1928,24 +1928,27 @@ add_packet_config_cmd (struct packet_config *config, const char *name, name, title); /* set/show TITLE-packet {auto,on,off} */ cmd_name = xstrprintf ("%s-packet", title); - add_setshow_auto_boolean_cmd (cmd_name, class_obscure, - &config->detect, set_doc, - show_doc, NULL, /* help_doc */ - NULL, - show_remote_protocol_packet_cmd, - &remote_set_cmdlist, &remote_show_cmdlist); + set_show_commands cmds + = add_setshow_auto_boolean_cmd (cmd_name, class_obscure, + &config->detect, set_doc, + show_doc, NULL, /* help_doc */ + NULL, + show_remote_protocol_packet_cmd, + &remote_set_cmdlist, &remote_show_cmdlist); + /* The command code copies the documentation strings. */ xfree (set_doc); xfree (show_doc); + /* set/show remote NAME-packet {auto,on,off} -- legacy. */ if (legacy) { char *legacy_name; legacy_name = xstrprintf ("%s-packet", name); - add_alias_cmd (legacy_name, cmd_name, class_obscure, 0, + add_alias_cmd (legacy_name, cmds.set, class_obscure, 0, &remote_set_cmdlist); - add_alias_cmd (legacy_name, cmd_name, class_obscure, 0, + add_alias_cmd (legacy_name, cmds.show, class_obscure, 0, &remote_show_cmdlist); } } diff --git a/gdb/solib.c b/gdb/solib.c index 5c8e6ca6366..2df52118143 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -1585,20 +1585,21 @@ inferior. Otherwise, symbols must be loaded manually, using \ show_auto_solib_add, &setlist, &showlist); - add_setshow_optional_filename_cmd ("sysroot", class_support, - &gdb_sysroot, _("\ + set_show_commands sysroot_cmds + = add_setshow_optional_filename_cmd ("sysroot", class_support, + &gdb_sysroot, _("\ Set an alternate system root."), _("\ Show the current system root."), _("\ The system root is used to load absolute shared library symbol files.\n\ For other (relative) files, you can add directories using\n\ `set solib-search-path'."), - gdb_sysroot_changed, - NULL, - &setlist, &showlist); + gdb_sysroot_changed, + NULL, + &setlist, &showlist); - add_alias_cmd ("solib-absolute-prefix", "sysroot", class_support, 0, + add_alias_cmd ("solib-absolute-prefix", sysroot_cmds.set, class_support, 0, &setlist); - add_alias_cmd ("solib-absolute-prefix", "sysroot", class_support, 0, + add_alias_cmd ("solib-absolute-prefix", sysroot_cmds.show, class_support, 0, &showlist); add_setshow_optional_filename_cmd ("solib-search-path", class_support, diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c index 3f9600f3879..4157594d153 100644 --- a/gdb/sparc64-tdep.c +++ b/gdb/sparc64-tdep.c @@ -535,9 +535,10 @@ _initialize_sparc64_adi_tdep () add_basic_prefix_cmd ("adi", class_support, _("ADI version related commands."), &sparc64adilist, 0, &cmdlist); - add_cmd ("examine", class_support, adi_examine_command, - _("Examine ADI versions."), &sparc64adilist); - add_alias_cmd ("x", "examine", no_class, 1, &sparc64adilist); + cmd_list_element *adi_examine_cmd + = add_cmd ("examine", class_support, adi_examine_command, + _("Examine ADI versions."), &sparc64adilist); + add_alias_cmd ("x", adi_examine_cmd, no_class, 1, &sparc64adilist); add_cmd ("assign", class_support, adi_assign_command, _("Assign ADI versions."), &sparc64adilist); diff --git a/gdb/symtab.c b/gdb/symtab.c index 9555f94707d..655b3dabf62 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -6897,11 +6897,12 @@ If zero then the symbol cache is disabled."), _("Print symbol cache statistics for each program space."), &maintenanceprintlist); - add_cmd ("symbol-cache", class_maintenance, - maintenance_flush_symbol_cache, - _("Flush the symbol cache for each program space."), - &maintenanceflushlist); - c = add_alias_cmd ("flush-symbol-cache", "flush symbol-cache", + cmd_list_element *maintenance_flush_symbol_cache_cmd + = add_cmd ("symbol-cache", class_maintenance, + maintenance_flush_symbol_cache, + _("Flush the symbol cache for each program space."), + &maintenanceflushlist); + c = add_alias_cmd ("flush-symbol-cache", maintenance_flush_symbol_cache_cmd, class_maintenance, 0, &maintenancelist); deprecate_cmd (c, "maintenancelist flush symbol-cache"); diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index abbd507c8b2..eca1a9d385c 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -4075,11 +4075,11 @@ Select a trace frame by PC.\n\ Default is the current PC, or the PC of the current trace frame."), &tfindlist); - add_cmd ("end", class_trace, tfind_end_command, _("\ -De-select any trace frame and resume 'live' debugging."), - &tfindlist); + cmd_list_element *tfind_end_cmd + = add_cmd ("end", class_trace, tfind_end_command, _("\ +De-select any trace frame and resume 'live' debugging."), &tfindlist); - add_alias_cmd ("none", "end", class_trace, 0, &tfindlist); + add_alias_cmd ("none", tfind_end_cmd, class_trace, 0, &tfindlist); add_cmd ("start", class_trace, tfind_start_command, _("Select the first trace frame in the trace buffer."), diff --git a/gdb/valprint.c b/gdb/valprint.c index e191c357fca..fa2b64ef10a 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -3143,18 +3143,20 @@ _initialize_valprint () { cmd_list_element *cmd; - add_basic_prefix_cmd ("print", no_class, - _("Generic command for setting how things print."), - &setprintlist, 0, &setlist); - add_alias_cmd ("p", "print", no_class, 1, &setlist); + cmd_list_element *set_print_cmd + = add_basic_prefix_cmd ("print", no_class, + _("Generic command for setting how things print."), + &setprintlist, 0, &setlist); + add_alias_cmd ("p", set_print_cmd, no_class, 1, &setlist); /* Prefer set print to set prompt. */ - add_alias_cmd ("pr", "print", no_class, 1, &setlist); - - add_show_prefix_cmd ("print", no_class, - _("Generic command for showing print settings."), - &showprintlist, 0, &showlist); - add_alias_cmd ("p", "print", no_class, 1, &showlist); - add_alias_cmd ("pr", "print", no_class, 1, &showlist); + add_alias_cmd ("pr", set_print_cmd, no_class, 1, &setlist); + + cmd_list_element *show_print_cmd + = add_show_prefix_cmd ("print", no_class, + _("Generic command for showing print settings."), + &showprintlist, 0, &showlist); + add_alias_cmd ("p", show_print_cmd, no_class, 1, &showlist); + add_alias_cmd ("pr", show_print_cmd, no_class, 1, &showlist); cmd = add_basic_prefix_cmd ("raw", no_class, _("\ diff --git a/gdb/value.c b/gdb/value.c index 9822cec209b..9df035a50b3 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -4231,7 +4231,8 @@ void _initialize_values (); void _initialize_values () { - add_cmd ("convenience", no_class, show_convenience, _("\ + cmd_list_element *show_convenience_cmd + = add_cmd ("convenience", no_class, show_convenience, _("\ Debugger convenience (\"$foo\") variables and functions.\n\ Convenience variables are created when you assign them values;\n\ thus, \"set $foo=1\" gives \"$foo\" the value 1. Values may be any type.\n\ @@ -4244,7 +4245,7 @@ A few convenience variables are given values automatically:\n\ Convenience functions are defined via the Python API." #endif ), &showlist); - add_alias_cmd ("conv", "convenience", no_class, 1, &showlist); + add_alias_cmd ("conv", show_convenience_cmd, no_class, 1, &showlist); add_cmd ("values", no_set_class, show_values, _("\ Elements of value history around item number IDX (or last ten)."), diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c index e6644843a95..88601e106f5 100644 --- a/gdb/windows-tdep.c +++ b/gdb/windows-tdep.c @@ -1212,10 +1212,11 @@ _initialize_windows_tdep () = gdbarch_data_register_post_init (init_windows_gdbarch_data); init_w32_command_list (); - add_cmd ("thread-information-block", class_info, display_tib, - _("Display thread information block."), - &info_w32_cmdlist); - add_alias_cmd ("tib", "thread-information-block", class_info, 1, + cmd_list_element *info_w32_thread_information_block_cmd + = add_cmd ("thread-information-block", class_info, display_tib, + _("Display thread information block."), + &info_w32_cmdlist); + add_alias_cmd ("tib", info_w32_thread_information_block_cmd, class_info, 1, &info_w32_cmdlist); add_setshow_boolean_cmd ("show-all-tib", class_maintenance, -- 2.30.2