From e0f25bd9717c7973197095523db7c1cdc956cea2 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 27 May 2021 13:59:01 -0400 Subject: [PATCH] gdb: make add_info_alias accept target as a cmd_list_element Same idea as previous patch, but for add_info_alias. gdb/ChangeLog: * command.h (add_info_alias): Accept target as cmd_list_element. Update callers. Change-Id: If830d423364bf42d7bea5ac4dd3a81adcfce6f7a --- gdb/ChangeLog | 5 +++++ gdb/breakpoint.c | 10 ++++++---- gdb/cli/cli-decode.c | 6 +++--- gdb/command.h | 5 +++-- gdb/guile/guile.c | 9 +++++---- gdb/infcmd.c | 7 ++++--- gdb/infrun.c | 5 +++-- gdb/solib.c | 7 ++++--- gdb/stack.c | 18 ++++++++++-------- 9 files changed, 43 insertions(+), 29 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5b04413509b..4279359ba33 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2021-05-27 Simon Marchi + + * command.h (add_info_alias): Accept target as + cmd_list_element. Update callers. + 2021-05-27 Simon Marchi * command.h (add_com_alias): Accept target as diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 1df0080dd52..ae05d1802a8 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -15870,7 +15870,8 @@ Convenience variable \"$bpnum\" contains the number of the last\n\ breakpoint set.")); } - add_info ("breakpoints", info_breakpoints_command, _("\ + cmd_list_element *info_breakpoints_cmd + = add_info ("breakpoints", info_breakpoints_command, _("\ Status of specified breakpoints (all user-settable breakpoints if no argument).\n\ The \"Type\" column indicates one of:\n\ \tbreakpoint - normal breakpoint\n\ @@ -15886,7 +15887,7 @@ is prefixed with \"server \".\n\n\ Convenience variable \"$bpnum\" contains the number of the last\n\ breakpoint set.")); - add_info_alias ("b", "breakpoints", 1); + add_info_alias ("b", info_breakpoints_cmd, 1); add_cmd ("breakpoints", class_maintenance, maintenance_info_breakpoints, _("\ Status of all breakpoints, or breakpoint number NUMBER.\n\ @@ -16053,12 +16054,13 @@ Do \"help breakpoints\" for info on other commands dealing with breakpoints.\n\ Do \"help tracepoints\" for info on other tracepoint commands.")); set_cmd_completer (c, location_completer); - add_info ("tracepoints", info_tracepoints_command, _("\ + cmd_list_element *info_tracepoints_cmd + = add_info ("tracepoints", info_tracepoints_command, _("\ Status of specified tracepoints (all tracepoints if no argument).\n\ Convenience variable \"$tpnum\" contains the number of the\n\ last tracepoint set.")); - add_info_alias ("tp", "tracepoints", 1); + add_info_alias ("tp", info_tracepoints_cmd, 1); add_cmd ("tracepoints", class_trace, delete_trace_command, _("\ Delete specified tracepoints.\n\ diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index dd649962188..2c2d72e2090 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -986,10 +986,10 @@ add_info (const char *name, cmd_const_cfunc_ftype *fun, const char *doc) /* Add an alias to the list of info subcommands. */ -struct cmd_list_element * -add_info_alias (const char *name, const char *target_name, int abbrev_flag) +cmd_list_element * +add_info_alias (const char *name, cmd_list_element *target, int abbrev_flag) { - return add_alias_cmd (name, target_name, class_run, abbrev_flag, &infolist); + return add_alias_cmd (name, target, class_run, abbrev_flag, &infolist); } /* Add an element to the list of commands. */ diff --git a/gdb/command.h b/gdb/command.h index 638de1efde9..e14f27b5f9a 100644 --- a/gdb/command.h +++ b/gdb/command.h @@ -373,8 +373,9 @@ extern struct cmd_list_element *add_info (const char *, cmd_const_cfunc_ftype *fun, const char *); -extern struct cmd_list_element *add_info_alias (const char *, const char *, - int); +extern cmd_list_element *add_info_alias (const char *name, + cmd_list_element *target, + int abbrev_flag); extern void complete_on_cmdlist (struct cmd_list_element *, completion_tracker &tracker, diff --git a/gdb/guile/guile.c b/gdb/guile/guile.c index a707c89b846..3b1fca3d20c 100644 --- a/gdb/guile/guile.c +++ b/gdb/guile/guile.c @@ -790,10 +790,11 @@ This command is only a placeholder.") &show_guile_list, 0, &showlist); add_alias_cmd ("gu", "guile", class_obscure, 1, &showlist); - add_basic_prefix_cmd ("guile", class_obscure, - _("Prefix command for Guile info displays."), - &info_guile_list, 0, &infolist); - add_info_alias ("gu", "guile", 1); + cmd_list_element *info_guile_cmd + = add_basic_prefix_cmd ("guile", class_obscure, + _("Prefix command for Guile info displays."), + &info_guile_list, 0, &infolist); + add_info_alias ("gu", info_guile_cmd, 1); /* The name "print-stack" is carried over from Python. A better name is "print-exception". */ diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 07d69b481fa..3cb05e564c3 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -3276,13 +3276,14 @@ If non-stop mode is enabled, interrupt only the current thread,\n\ otherwise all the threads in the program are stopped. To \n\ interrupt all running threads in non-stop mode, use the -a option.")); - c = add_info ("registers", info_registers_command, _("\ + cmd_list_element *info_registers_cmd + = add_info ("registers", info_registers_command, _("\ List of integer registers and their contents, for selected stack frame.\n\ One or more register names as argument means describe the given registers.\n\ One or more register group names as argument means describe the registers\n\ in the named register groups.")); - add_info_alias ("r", "registers", 1); - set_cmd_completer (c, reg_or_group_completer); + add_info_alias ("r", info_registers_cmd, 1); + set_cmd_completer (info_registers_cmd, reg_or_group_completer); c = add_info ("all-registers", info_all_registers_command, _("\ List of all registers and their contents, for selected stack frame.\n\ diff --git a/gdb/infrun.c b/gdb/infrun.c index 7fc56dc51f0..427c694bb76 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -9501,10 +9501,11 @@ _initialize_infrun () = create_async_event_handler (infrun_async_inferior_event_handler, NULL, "infrun"); - add_info ("signals", info_signals_command, _("\ + cmd_list_element *info_signals_cmd + = add_info ("signals", info_signals_command, _("\ What debugger does when program gets various signals.\n\ Specify a signal as argument to print info on that signal only.")); - add_info_alias ("handle", "signals", 0); + add_info_alias ("handle", info_signals_cmd, 0); c = add_com ("handle", class_run, handle_command, _("\ Specify how to handle signals.\n\ diff --git a/gdb/solib.c b/gdb/solib.c index f3cd48fde77..5c8e6ca6366 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -1565,9 +1565,10 @@ _initialize_solib () add_com ("sharedlibrary", class_files, sharedlibrary_command, _("Load shared object library symbols for files matching REGEXP.")); - add_info ("sharedlibrary", info_sharedlibrary_command, - _("Status of loaded shared object libraries.")); - add_info_alias ("dll", "sharedlibrary", 1); + cmd_list_element *info_sharedlibrary_cmd + = add_info ("sharedlibrary", info_sharedlibrary_command, + _("Status of loaded shared object libraries.")); + add_info_alias ("dll", info_sharedlibrary_cmd, 1); add_com ("nosharedlibrary", class_files, no_shared_libraries, _("Unload all shared object library symbols.")); diff --git a/gdb/stack.c b/gdb/stack.c index a3a6ba6c419..66a46101993 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -3508,17 +3508,19 @@ With a negative COUNT, print outermost -COUNT frames."), add_com_alias ("bt", backtrace_cmd, 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); - - add_prefix_cmd ("frame", class_info, &info_frame_cmd.base_command, - _("All about the selected stack frame.\n\ + cmd_list_element *info_stack_cmd + = add_info ("stack", backtrace_command, + _("Backtrace of the stack, or innermost COUNT frames.")); + add_info_alias ("s", info_stack_cmd, 1); + + cmd_list_element *info_frame_cmd_el + = add_prefix_cmd ("frame", class_info, &info_frame_cmd.base_command, + _("All about the selected stack frame.\n\ With no arguments, displays information about the currently selected stack\n\ frame. Alternatively a frame specification may be provided (See \"frame\")\n\ the information is then printed about the specified frame."), - &info_frame_cmd_list, 1, &infolist); - add_info_alias ("f", "frame", 1); + &info_frame_cmd_list, 1, &infolist); + add_info_alias ("f", info_frame_cmd_el, 1); add_cmd ("address", class_stack, &info_frame_cmd.address, _("\ -- 2.30.2