diff options
author | Tom Tromey <tromey@adacore.com> | 2020-04-17 07:27:14 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2020-04-17 15:13:41 -0600 |
commit | 0743fc83c03da263953dfc393a66744a08770365 (patch) | |
tree | d796bc15c865a74b85d1b2227ce982f25f8340ee /gdb/maint.c | |
parent | e409955ddcc33743044f217a3cc0541e0e6211b7 (diff) | |
download | gdb-0743fc83c03da263953dfc393a66744a08770365.zip gdb-0743fc83c03da263953dfc393a66744a08770365.tar.gz gdb-0743fc83c03da263953dfc393a66744a08770365.tar.bz2 |
Replace most calls to help_list and cmd_show_list
Currently there are many prefix commands that do nothing but call
either help_list or cmd_show_list. I happened to notice that one such
call, for "set print type", used the wrong command list parameter,
causing incorrect output.
Rather than fix this bug in isolation, I decided to eliminate this
possibility by adding two new ways to add prefix commands, which
simply route the call to help_list or cmd_show_list, as appropriate.
This makes it impossible for a mismatch to occur.
In some cases, a bit of output was removed; however, I don't think
this output in general was very useful. It seemed redundant with
what's already printed by help_list. A representative example is this
hunk, removed from ada-lang.c:
- printf_unfiltered (_(\
-"\"set ada\" must be followed by the name of a setting.\n"));
This simplified the CLI style set/show commands quite a bit, and
allowed the deletion of a macro.
This also cleans up some unusual code in windows-tdep.c.
Tested on x86-64 Fedora 30. Note that I have no way to build the
go32-nat.c change.
gdb/ChangeLog
2020-04-17 Tom Tromey <tromey@adacore.com>
* auto-load.c (show_auto_load_cmd): Remove.
(auto_load_show_cmdlist_get): Use add_show_prefix_cmd.
* arc-tdep.c (_initialize_arc_tdep): Use add_show_prefix_cmd.
(maintenance_print_arc_command): Remove.
* tui/tui-win.c (tui_command): Remove.
(tui_get_cmd_list): Use add_basic_prefix_cmd.
* tui/tui-layout.c (tui_layout_command): Remove.
(_initialize_tui_layout): Use add_basic_prefix_cmd.
* python/python.c (user_set_python, user_show_python): Remove.
(_initialize_python): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* guile/guile.c (set_guile_command, show_guile_command): Remove.
(install_gdb_commands): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
(info_guile_command): Remove.
* dwarf2/read.c (set_dwarf_cmd, show_dwarf_cmd): Remove.
(_initialize_dwarf2_read): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* cli/cli-style.h (class cli_style_option) <add_setshow_commands>:
Remove do_set and do_show parameters.
* cli/cli-style.c (set_style, show_style): Remove.
(_initialize_cli_style): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
(cli_style_option::add_setshow_commands): Remove do_set and
do_show parameters.
(cli_style_option::add_setshow_commands): Use
add_basic_prefix_cmd, add_show_prefix_cmd.
(STYLE_ADD_SETSHOW_COMMANDS): Remove macro.
(set_style_name): Remove.
* cli/cli-dump.c (dump_command, append_command): Remove.
(srec_dump_command, ihex_dump_command, verilog_dump_command)
(tekhex_dump_command, binary_dump_command)
(binary_append_command): Remove.
(_initialize_cli_dump): Use add_basic_prefix_cmd.
* windows-tdep.c (w32_prefix_command_valid): Remove global.
(init_w32_command_list): Remove; move into ...
(_initialize_windows_tdep): ... here. Use add_basic_prefix_cmd.
* valprint.c (set_print, show_print, set_print_raw)
(show_print_raw): Remove.
(_initialize_valprint): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* typeprint.c (set_print_type, show_print_type): Remove.
(_initialize_typeprint): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* record.c (set_record_command, show_record_command): Remove.
(_initialize_record): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* cli/cli-cmds.c (_initialize_cli_cmds): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
(info_command, show_command, set_debug, show_debug): Remove.
* top.h (set_history, show_history): Don't declare.
* top.c (set_history, show_history): Remove.
* target-descriptions.c (set_tdesc_cmd, show_tdesc_cmd)
(unset_tdesc_cmd): Remove.
(_initialize_target_descriptions): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* symtab.c (info_module_command): Remove.
(_initialize_symtab): Use add_basic_prefix_cmd.
* symfile.c (overlay_command): Remove.
(_initialize_symfile): Use add_basic_prefix_cmd.
* sparc64-tdep.c (info_adi_command): Remove.
(_initialize_sparc64_adi_tdep): Use add_basic_prefix_cmd.
* sh-tdep.c (show_sh_command, set_sh_command): Remove.
(_initialize_sh_tdep): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* serial.c (serial_set_cmd, serial_show_cmd): Remove.
(_initialize_serial): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* ser-tcp.c (set_tcp_cmd, show_tcp_cmd): Remove.
(_initialize_ser_tcp): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* rs6000-tdep.c (set_powerpc_command, show_powerpc_command)
(_initialize_rs6000_tdep): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* riscv-tdep.c (show_riscv_command, set_riscv_command)
(show_debug_riscv_command, set_debug_riscv_command): Remove.
(_initialize_riscv_tdep): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* remote.c (remote_command, set_remote_cmd): Remove.
(_initialize_remote): Use add_basic_prefix_cmd.
* record-full.c (set_record_full_command)
(show_record_full_command): Remove.
(_initialize_record_full): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* record-btrace.c (cmd_set_record_btrace)
(cmd_show_record_btrace, cmd_set_record_btrace_bts)
(cmd_show_record_btrace_bts, cmd_set_record_btrace_pt)
(cmd_show_record_btrace_pt): Remove.
(_initialize_record_btrace): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* ravenscar-thread.c (set_ravenscar_command)
(show_ravenscar_command): Remove.
(_initialize_ravenscar): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* mips-tdep.c (show_mips_command, set_mips_command)
(_initialize_mips_tdep): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* maint.c (maintenance_command, maintenance_info_command)
(maintenance_check_command, maintenance_print_command)
(maintenance_set_cmd, maintenance_show_cmd): Remove.
(_initialize_maint_cmds): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
(show_per_command_cmd): Remove.
* maint-test-settings.c (maintenance_set_test_settings_cmd):
Remove.
(maintenance_show_test_settings_cmd): Remove.
(_initialize_maint_test_settings): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* maint-test-options.c (maintenance_test_options_command):
Remove.
(_initialize_maint_test_options): Use add_basic_prefix_cmd.
* macrocmd.c (macro_command): Remove
(_initialize_macrocmd): Use add_basic_prefix_cmd.
* language.c (set_check, show_check): Remove.
(_initialize_language): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* infcmd.c (unset_command): Remove.
(_initialize_infcmd): Use add_basic_prefix_cmd.
* i386-tdep.c (set_mpx_cmd, show_mpx_cmd): Remove.
(_initialize_i386_tdep): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* go32-nat.c (go32_info_dos_command): Remove.
(_initialize_go32_nat): Use add_basic_prefix_cmd.
* cli/cli-decode.c (do_prefix_cmd, add_basic_prefix_cmd)
(do_show_prefix_cmd, add_show_prefix_cmd): New functions.
* frame.c (set_backtrace_cmd, show_backtrace_cmd): Remove.
(_initialize_frame): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* dcache.c (set_dcache_command, show_dcache_command): Remove.
(_initialize_dcache): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* cp-support.c (maint_cplus_command): Remove.
(_initialize_cp_support): Use add_basic_prefix_cmd.
* btrace.c (maint_btrace_cmd, maint_btrace_set_cmd)
(maint_btrace_show_cmd, maint_btrace_pt_set_cmd)
(maint_btrace_pt_show_cmd, _initialize_btrace): Use
add_basic_prefix_cmd, add_show_prefix_cmd.
* breakpoint.c (save_command): Remove.
(_initialize_breakpoint): Use add_basic_prefix_cmd.
* arm-tdep.c (set_arm_command, show_arm_command): Remove.
(_initialize_arm_tdep): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* ada-lang.c (maint_set_ada_cmd, maint_show_ada_cmd)
(set_ada_command, show_ada_command): Remove.
(_initialize_ada_language): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* command.h (add_basic_prefix_cmd, add_show_prefix_cmd): Declare.
gdb/testsuite/ChangeLog
2020-04-17 Tom Tromey <tromey@adacore.com>
* gdb.cp/maint.exp (test_help): Simplify multiple_help_body.
Update tests.
* gdb.btrace/cpu.exp: Update tests.
* gdb.base/maint.exp: Update tests.
* gdb.base/default.exp: Update tests.
* gdb.base/completion.exp: Update tests.
Diffstat (limited to 'gdb/maint.c')
-rw-r--r-- | gdb/maint.c | 120 |
1 files changed, 24 insertions, 96 deletions
diff --git a/gdb/maint.c b/gdb/maint.c index e8e0f28..b4890c3 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -52,16 +52,6 @@ static void maintenance_do_deprecate (const char *, int); -/* Access the maintenance subcommands. */ - -static void -maintenance_command (const char *args, int from_tty) -{ - printf_unfiltered (_("\"maintenance\" must be followed by " - "the name of a maintenance command.\n")); - help_list (maintenancelist, "maintenance ", all_commands, gdb_stdout); -} - #ifndef _WIN32 static void maintenance_dump_me (const char *args, int from_tty) @@ -139,32 +129,6 @@ maintenance_space_display (const char *args, int from_tty) set_per_command_space (strtol (args, NULL, 10)); } -/* The "maintenance info" command is defined as a prefix, with - allow_unknown 0. Therefore, its own definition is called only for - "maintenance info" with no args. */ - -static void -maintenance_info_command (const char *arg, int from_tty) -{ - printf_unfiltered (_("\"maintenance info\" must be followed " - "by the name of an info command.\n")); - help_list (maintenanceinfolist, "maintenance info ", all_commands, - gdb_stdout); -} - -/* The "maintenance check" command is defined as a prefix, with - allow_unknown 0. Therefore, its own definition is called only for - "maintenance check" with no args. */ - -static void -maintenance_check_command (const char *arg, int from_tty) -{ - printf_unfiltered (_("\"maintenance check\" must be followed " - "by the name of a check command.\n")); - help_list (maintenancechecklist, "maintenance check ", all_commands, - gdb_stdout); -} - /* Mini tokenizing lexer for 'maint info sections' command. */ static int @@ -511,19 +475,6 @@ maintenance_print_architecture (const char *args, int from_tty) } } -/* The "maintenance print" command is defined as a prefix, with - allow_unknown 0. Therefore, its own definition is called only for - "maintenance print" with no args. */ - -static void -maintenance_print_command (const char *arg, int from_tty) -{ - printf_unfiltered (_("\"maintenance print\" must be followed " - "by the name of a print command.\n")); - help_list (maintenanceprintlist, "maintenance print ", all_commands, - gdb_stdout); -} - /* The "maintenance translate-address" command converts a section and address to a symbol. This can be called in two ways: maintenance translate-address <secname> <addr> @@ -739,21 +690,6 @@ maintenance_do_deprecate (const char *text, int deprecate) struct cmd_list_element *maintenance_set_cmdlist; struct cmd_list_element *maintenance_show_cmdlist; -static void -maintenance_set_cmd (const char *args, int from_tty) -{ - printf_unfiltered (_("\"maintenance set\" must be followed " - "by the name of a set command.\n")); - help_list (maintenance_set_cmdlist, "maintenance set ", all_commands, - gdb_stdout); -} - -static void -maintenance_show_cmd (const char *args, int from_tty) -{ - cmd_show_list (maintenance_show_cmdlist, from_tty, ""); -} - /* "maintenance with" command. */ static void @@ -1097,14 +1033,6 @@ set_per_command_cmd (const char *args, int from_tty) } } -/* Command "show per-command" displays summary of all the current - "show per-command " settings. */ - -static void -show_per_command_cmd (const char *args, int from_tty) -{ - cmd_show_list (per_command_showlist, from_tty, ""); -} /* The "maintenance selftest" command. */ @@ -1141,19 +1069,19 @@ _initialize_maint_cmds () { struct cmd_list_element *cmd; - add_prefix_cmd ("maintenance", class_maintenance, maintenance_command, _("\ + 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, "maintenance ", 0, - &cmdlist); + &maintenancelist, "maintenance ", 0, + &cmdlist); add_com_alias ("mt", "maintenance", class_maintenance, 1); - add_prefix_cmd ("info", class_maintenance, maintenance_info_command, _("\ + add_basic_prefix_cmd ("info", class_maintenance, _("\ Commands for showing internal info about the program being debugged."), - &maintenanceinfolist, "maintenance info ", 0, - &maintenancelist); + &maintenanceinfolist, "maintenance info ", 0, + &maintenancelist); add_alias_cmd ("i", "info", class_maintenance, 1, &maintenancelist); add_cmd ("sections", class_maintenance, maintenance_info_sections, _("\ @@ -1168,24 +1096,24 @@ implies all sections). In addition, the special argument\n\ lists all sections from all object files, including shared libraries."), &maintenanceinfolist); - add_prefix_cmd ("print", class_maintenance, maintenance_print_command, - _("Maintenance command for printing GDB internal state."), - &maintenanceprintlist, "maintenance print ", 0, - &maintenancelist); + add_basic_prefix_cmd ("print", class_maintenance, + _("Maintenance command for printing GDB internal state."), + &maintenanceprintlist, "maintenance print ", 0, + &maintenancelist); - add_prefix_cmd ("set", class_maintenance, maintenance_set_cmd, _("\ + add_basic_prefix_cmd ("set", class_maintenance, _("\ Set GDB internal variables used by the GDB maintainer.\n\ Configure variables internal to GDB that aid in GDB's maintenance"), - &maintenance_set_cmdlist, "maintenance set ", - 0/*allow-unknown*/, - &maintenancelist); + &maintenance_set_cmdlist, "maintenance set ", + 0/*allow-unknown*/, + &maintenancelist); - add_prefix_cmd ("show", class_maintenance, maintenance_show_cmd, _("\ + add_show_prefix_cmd ("show", class_maintenance, _("\ Show GDB internal variables used by the GDB maintainer.\n\ Configure variables internal to GDB that aid in GDB's maintenance"), - &maintenance_show_cmdlist, "maintenance show ", - 0/*allow-unknown*/, - &maintenancelist); + &maintenance_show_cmdlist, "maintenance show ", + 0/*allow-unknown*/, + &maintenancelist); cmd = add_cmd ("with", class_maintenance, maintenance_with_cmd, _("\ Like \"with\", but works with \"maintenance set\" variables.\n\ @@ -1232,10 +1160,10 @@ Per-command statistics settings."), &per_command_setlist, "maintenance set per-command ", 1/*allow-unknown*/, &maintenance_set_cmdlist); - add_prefix_cmd ("per-command", class_maintenance, show_per_command_cmd, _("\ + add_show_prefix_cmd ("per-command", class_maintenance, _("\ Show per-command statistics settings."), - &per_command_showlist, "maintenance show per-command ", - 0/*allow-unknown*/, &maintenance_show_cmdlist); + &per_command_showlist, "maintenance show per-command ", + 0/*allow-unknown*/, &maintenance_show_cmdlist); add_setshow_boolean_cmd ("time", class_maintenance, &per_command_time, _("\ @@ -1299,10 +1227,10 @@ Print the internal architecture configuration.\n\ Takes an optional file parameter."), &maintenanceprintlist); - add_prefix_cmd ("check", class_maintenance, maintenance_check_command, _("\ + add_basic_prefix_cmd ("check", class_maintenance, _("\ Commands for checking internal gdb state."), - &maintenancechecklist, "maintenance check ", 0, - &maintenancelist); + &maintenancechecklist, "maintenance check ", 0, + &maintenancelist); add_cmd ("translate-address", class_maintenance, maintenance_translate_address, |