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/cli | |
parent | e409955ddcc33743044f217a3cc0541e0e6211b7 (diff) | |
download | binutils-0743fc83c03da263953dfc393a66744a08770365.zip binutils-0743fc83c03da263953dfc393a66744a08770365.tar.gz binutils-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/cli')
-rw-r--r-- | gdb/cli/cli-cmds.c | 69 | ||||
-rw-r--r-- | gdb/cli/cli-decode.c | 52 | ||||
-rw-r--r-- | gdb/cli/cli-dump.c | 147 | ||||
-rw-r--r-- | gdb/cli/cli-style.c | 126 | ||||
-rw-r--r-- | gdb/cli/cli-style.h | 2 |
5 files changed, 158 insertions, 238 deletions
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 6f32441..f717851 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -191,26 +191,6 @@ error_no_arg (const char *why) error (_("Argument required (%s)."), why); } -/* The "info" command is defined as a prefix, with allow_unknown = 0. - Therefore, its own definition is called only for "info" with no - args. */ - -static void -info_command (const char *arg, int from_tty) -{ - printf_unfiltered (_("\"info\" must be followed by " - "the name of an info command.\n")); - help_list (infolist, "info ", all_commands, gdb_stdout); -} - -/* The "show" command with no arguments shows all the settings. */ - -static void -show_command (const char *arg, int from_tty) -{ - cmd_show_list (showlist, from_tty, ""); -} - /* See cli/cli-cmds.h. */ void @@ -1852,20 +1832,6 @@ filter_sals (std::vector<symtab_and_line> &sals) sals.erase (from, sals.end ()); } -static void -set_debug (const char *arg, int from_tty) -{ - printf_unfiltered (_("\"set debug\" must be followed by " - "the name of a debug subcommand.\n")); - help_list (setdebuglist, "set debug ", all_commands, gdb_stdout); -} - -static void -show_debug (const char *args, int from_tty) -{ - cmd_show_list (showdebuglist, from_tty, ""); -} - void init_cmd_lists (void) { @@ -2208,12 +2174,12 @@ Show verbosity."), NULL, show_info_verbose, &setlist, &showlist); - add_prefix_cmd ("history", class_support, set_history, - _("Generic command for setting command history parameters."), - &sethistlist, "set history ", 0, &setlist); - add_prefix_cmd ("history", class_support, show_history, - _("Generic command for showing command history parameters."), - &showhistlist, "show history ", 0, &showlist); + add_basic_prefix_cmd ("history", class_support, _("\ +Generic command for setting command history parameters."), + &sethistlist, "set history ", 0, &setlist); + add_show_prefix_cmd ("history", class_support, _("\ +Generic command for showing command history parameters."), + &showhistlist, "show history ", 0, &showlist); add_setshow_boolean_cmd ("expansion", no_class, &history_expansion_p, _("\ Set history expansion on command input."), _("\ @@ -2223,20 +2189,21 @@ Without an argument, history expansion is enabled."), show_history_expansion_p, &sethistlist, &showhistlist); - add_prefix_cmd ("info", class_info, info_command, _("\ + add_basic_prefix_cmd ("info", class_info, _("\ Generic command for showing things about the program being debugged."), - &infolist, "info ", 0, &cmdlist); + &infolist, "info ", 0, &cmdlist); add_com_alias ("i", "info", class_info, 1); add_com_alias ("inf", "info", class_info, 1); add_com ("complete", class_obscure, complete_command, _("List the completions for the rest of the line as a command.")); - add_prefix_cmd ("show", class_info, show_command, _("\ + add_show_prefix_cmd ("show", class_info, _("\ Generic command for showing things about the debugger."), - &showlist, "show ", 0, &cmdlist); + &showlist, "show ", 0, &cmdlist); /* Another way to get at the same thing. */ - add_info ("set", show_command, _("Show all GDB settings.")); + add_show_prefix_cmd ("set", class_info, _("Show all GDB settings."), + &showlist, "info set ", 0, &infolist); c = add_com ("with", class_vars, with_command, _("\ Temporarily set SETTING to VALUE, run COMMAND, and restore SETTING.\n\ @@ -2324,13 +2291,13 @@ from the target."), show_remote_timeout, &setlist, &showlist); - add_prefix_cmd ("debug", no_class, set_debug, - _("Generic command for setting gdb debugging flags."), - &setdebuglist, "set debug ", 0, &setlist); + add_basic_prefix_cmd ("debug", no_class, + _("Generic command for setting gdb debugging flags."), + &setdebuglist, "set debug ", 0, &setlist); - add_prefix_cmd ("debug", no_class, show_debug, - _("Generic command for showing gdb debugging flags."), - &showdebuglist, "show debug ", 0, &showlist); + add_show_prefix_cmd ("debug", no_class, + _("Generic command for showing gdb debugging flags."), + &showdebuglist, "show debug ", 0, &showlist); c = add_com ("shell", class_support, shell_command, _("\ Execute the rest of the line as a shell command.\n\ diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 7aecd98..17f49ec 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -380,6 +380,58 @@ add_prefix_cmd (const char *name, enum command_class theclass, return c; } +/* A helper function for add_basic_prefix_cmd. This is a command + function that just forwards to help_list. */ + +static void +do_prefix_cmd (const char *args, int from_tty, struct cmd_list_element *c) +{ + /* Look past all aliases. */ + while (c->cmd_pointer != nullptr) + c = c->cmd_pointer; + + help_list (*c->prefixlist, c->prefixname, all_commands, gdb_stdout); +} + +/* See command.h. */ + +struct cmd_list_element * +add_basic_prefix_cmd (const char *name, enum command_class theclass, + const char *doc, struct cmd_list_element **prefixlist, + const char *prefixname, int allow_unknown, + struct cmd_list_element **list) +{ + struct cmd_list_element *cmd = add_prefix_cmd (name, theclass, nullptr, + doc, prefixlist, prefixname, + allow_unknown, list); + set_cmd_sfunc (cmd, do_prefix_cmd); + return cmd; +} + +/* A helper function for add_show_prefix_cmd. This is a command + function that just forwards to cmd_show_list. */ + +static void +do_show_prefix_cmd (const char *args, int from_tty, struct cmd_list_element *c) +{ + cmd_show_list (*c->prefixlist, from_tty, ""); +} + +/* See command.h. */ + +struct cmd_list_element * +add_show_prefix_cmd (const char *name, enum command_class theclass, + const char *doc, struct cmd_list_element **prefixlist, + const char *prefixname, int allow_unknown, + struct cmd_list_element **list) +{ + struct cmd_list_element *cmd = add_prefix_cmd (name, theclass, nullptr, + doc, prefixlist, prefixname, + allow_unknown, list); + set_cmd_sfunc (cmd, do_show_prefix_cmd); + return cmd; +} + /* Like ADD_PREFIX_CMD but sets the suppress_notification pointer on the new command list element. */ diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c index ae047ac..567ef2e 100644 --- a/gdb/cli/cli-dump.c +++ b/gdb/cli/cli-dump.c @@ -129,20 +129,6 @@ static struct cmd_list_element *binary_dump_cmdlist; static struct cmd_list_element *binary_append_cmdlist; static void -dump_command (const char *cmd, int from_tty) -{ - printf_unfiltered (_("\"dump\" must be followed by a subcommand.\n\n")); - help_list (dump_cmdlist, "dump ", all_commands, gdb_stdout); -} - -static void -append_command (const char *cmd, int from_tty) -{ - printf_unfiltered (_("\"append\" must be followed by a subcommand.\n\n")); - help_list (dump_cmdlist, "append ", all_commands, gdb_stdout); -} - -static void dump_binary_file (const char *filename, const char *mode, const bfd_byte *buf, ULONGEST len) { @@ -579,65 +565,22 @@ restore_command (const char *args, int from_tty) } } -static void -srec_dump_command (const char *cmd, int from_tty) -{ - printf_unfiltered (_("\"dump srec\" must be followed by a subcommand.\n")); - help_list (srec_cmdlist, "dump srec ", all_commands, gdb_stdout); -} - -static void -ihex_dump_command (const char *cmd, int from_tty) -{ - printf_unfiltered (_("\"dump ihex\" must be followed by a subcommand.\n")); - help_list (ihex_cmdlist, "dump ihex ", all_commands, gdb_stdout); -} - -static void -verilog_dump_command (const char *cmd, int from_tty) -{ - printf_unfiltered (_("\"dump verilog\" must be followed by a subcommand.\n")); - help_list (verilog_cmdlist, "dump verilog ", all_commands, gdb_stdout); -} - -static void -tekhex_dump_command (const char *cmd, int from_tty) -{ - printf_unfiltered (_("\"dump tekhex\" must be followed by a subcommand.\n")); - help_list (tekhex_cmdlist, "dump tekhex ", all_commands, gdb_stdout); -} - -static void -binary_dump_command (const char *cmd, int from_tty) -{ - printf_unfiltered (_("\"dump binary\" must be followed by a subcommand.\n")); - help_list (binary_dump_cmdlist, "dump binary ", all_commands, gdb_stdout); -} - -static void -binary_append_command (const char *cmd, int from_tty) -{ - printf_unfiltered (_("\"append binary\" must be followed by a subcommand.\n")); - help_list (binary_append_cmdlist, "append binary ", all_commands, - gdb_stdout); -} - void _initialize_cli_dump (); void _initialize_cli_dump () { struct cmd_list_element *c; - add_prefix_cmd ("dump", class_vars, dump_command, - _("Dump target code/data to a local file."), - &dump_cmdlist, "dump ", - 0/*allow-unknown*/, - &cmdlist); - add_prefix_cmd ("append", class_vars, append_command, - _("Append target code/data to a local file."), - &append_cmdlist, "append ", - 0/*allow-unknown*/, - &cmdlist); + add_basic_prefix_cmd ("dump", class_vars, + _("Dump target code/data to a local file."), + &dump_cmdlist, "dump ", + 0/*allow-unknown*/, + &cmdlist); + add_basic_prefix_cmd ("append", class_vars, + _("Append target code/data to a local file."), + &append_cmdlist, "append ", + 0/*allow-unknown*/, + &cmdlist); add_dump_command ("memory", dump_memory_command, "\ Write contents of memory to a raw binary file.\n\ @@ -649,41 +592,41 @@ Write the value of an expression to a raw binary file.\n\ Arguments are FILE EXPRESSION. Writes the value of EXPRESSION to\n\ the specified FILE in raw target ordered bytes."); - add_prefix_cmd ("srec", all_commands, srec_dump_command, - _("Write target code/data to an srec file."), - &srec_cmdlist, "dump srec ", - 0 /*allow-unknown*/, - &dump_cmdlist); - - add_prefix_cmd ("ihex", all_commands, ihex_dump_command, - _("Write target code/data to an intel hex file."), - &ihex_cmdlist, "dump ihex ", - 0 /*allow-unknown*/, - &dump_cmdlist); - - add_prefix_cmd ("verilog", all_commands, verilog_dump_command, - _("Write target code/data to a verilog hex file."), - &verilog_cmdlist, "dump verilog ", - 0 /*allow-unknown*/, - &dump_cmdlist); - - add_prefix_cmd ("tekhex", all_commands, tekhex_dump_command, - _("Write target code/data to a tekhex file."), - &tekhex_cmdlist, "dump tekhex ", - 0 /*allow-unknown*/, - &dump_cmdlist); - - add_prefix_cmd ("binary", all_commands, binary_dump_command, - _("Write target code/data to a raw binary file."), - &binary_dump_cmdlist, "dump binary ", - 0 /*allow-unknown*/, - &dump_cmdlist); - - add_prefix_cmd ("binary", all_commands, binary_append_command, - _("Append target code/data to a raw binary file."), - &binary_append_cmdlist, "append binary ", - 0 /*allow-unknown*/, - &append_cmdlist); + add_basic_prefix_cmd ("srec", all_commands, + _("Write target code/data to an srec file."), + &srec_cmdlist, "dump srec ", + 0 /*allow-unknown*/, + &dump_cmdlist); + + add_basic_prefix_cmd ("ihex", all_commands, + _("Write target code/data to an intel hex file."), + &ihex_cmdlist, "dump ihex ", + 0 /*allow-unknown*/, + &dump_cmdlist); + + add_basic_prefix_cmd ("verilog", all_commands, + _("Write target code/data to a verilog hex file."), + &verilog_cmdlist, "dump verilog ", + 0 /*allow-unknown*/, + &dump_cmdlist); + + add_basic_prefix_cmd ("tekhex", all_commands, + _("Write target code/data to a tekhex file."), + &tekhex_cmdlist, "dump tekhex ", + 0 /*allow-unknown*/, + &dump_cmdlist); + + add_basic_prefix_cmd ("binary", all_commands, + _("Write target code/data to a raw binary file."), + &binary_dump_cmdlist, "dump binary ", + 0 /*allow-unknown*/, + &dump_cmdlist); + + add_basic_prefix_cmd ("binary", all_commands, + _("Append target code/data to a raw binary file."), + &binary_append_cmdlist, "append binary ", + 0 /*allow-unknown*/, + &append_cmdlist); add_cmd ("memory", all_commands, dump_srec_memory, _("\ Write contents of memory to an srec file.\n\ diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c index d2d9928..a0c3cc5 100644 --- a/gdb/cli/cli-style.c +++ b/gdb/cli/cli-style.c @@ -215,20 +215,16 @@ void cli_style_option::add_setshow_commands (enum command_class theclass, const char *prefix_doc, struct cmd_list_element **set_list, - void (*do_set) (const char *args, - int from_tty), struct cmd_list_element **show_list, - void (*do_show) (const char *args, - int from_tty), bool skip_intensity) { m_set_prefix = std::string ("set style ") + m_name + " "; m_show_prefix = std::string ("show style ") + m_name + " "; - add_prefix_cmd (m_name, no_class, do_set, prefix_doc, &m_set_list, - m_set_prefix.c_str (), 0, set_list); - add_prefix_cmd (m_name, no_class, do_show, prefix_doc, &m_show_list, - m_show_prefix.c_str (), 0, show_list); + add_basic_prefix_cmd (m_name, no_class, prefix_doc, &m_set_list, + m_set_prefix.c_str (), 0, set_list); + add_show_prefix_cmd (m_name, no_class, prefix_doc, &m_show_list, + m_show_prefix.c_str (), 0, show_list); add_setshow_enum_cmd ("foreground", theclass, cli_colors, &m_foreground, @@ -261,20 +257,6 @@ static cmd_list_element *style_set_list; static cmd_list_element *style_show_list; static void -set_style (const char *arg, int from_tty) -{ - printf_unfiltered (_("\"set style\" must be followed " - "by an appropriate subcommand.\n")); - help_list (style_set_list, "set style ", all_commands, gdb_stdout); -} - -static void -show_style (const char *arg, int from_tty) -{ - cmd_show_list (style_show_list, from_tty, ""); -} - -static void set_style_enabled (const char *args, int from_tty, struct cmd_list_element *c) { g_source_cache.clear (); @@ -301,27 +283,15 @@ show_style_sources (struct ui_file *file, int from_tty, fprintf_filtered (file, _("Source code styling is disabled.\n")); } -/* Builds the "set style NAME " prefix. */ - -static std::string -set_style_name (const char *name) -{ - std::string result ("set style "); - - result += name; - result += " "; - return result; -} - void _initialize_cli_style (); void _initialize_cli_style () { - add_prefix_cmd ("style", no_class, set_style, _("\ + add_basic_prefix_cmd ("style", no_class, _("\ Style-specific settings.\n\ Configure various style-related variables, such as colors"), &style_set_list, "set style ", 0, &setlist); - add_prefix_cmd ("style", no_class, show_style, _("\ + add_show_prefix_cmd ("style", no_class, _("\ Style-specific settings.\n\ Configure various style-related variables, such as colors"), &style_show_list, "show style ", 0, &showlist); @@ -348,78 +318,68 @@ available if the appropriate extension is available at runtime." ), set_style_enabled, show_style_sources, &style_set_list, &style_show_list); -#define STYLE_ADD_SETSHOW_COMMANDS(STYLE, PREFIX_DOC, SKIP) \ - STYLE.add_setshow_commands (no_class, PREFIX_DOC, \ - &style_set_list, \ - [] (const char *args, int from_tty) \ - { \ - help_list \ - (STYLE.set_list (), \ - set_style_name (STYLE.name ()).c_str (), \ - all_commands, \ - gdb_stdout); \ - }, \ - &style_show_list, \ - [] (const char *args, int from_tty) \ - { \ - cmd_show_list \ - (STYLE.show_list (), \ - from_tty, \ - ""); \ - }, SKIP) - - STYLE_ADD_SETSHOW_COMMANDS (file_name_style, - _("\ + file_name_style.add_setshow_commands (no_class, _("\ Filename display styling.\n\ -Configure filename colors and display intensity."), false); +Configure filename colors and display intensity."), + &style_set_list, &style_show_list, + false); - STYLE_ADD_SETSHOW_COMMANDS (function_name_style, - _("\ + function_name_style.add_setshow_commands (no_class, _("\ Function name display styling.\n\ -Configure function name colors and display intensity"), false); +Configure function name colors and display intensity"), + &style_set_list, &style_show_list, + false); - STYLE_ADD_SETSHOW_COMMANDS (variable_name_style, - _("\ + variable_name_style.add_setshow_commands (no_class, _("\ Variable name display styling.\n\ -Configure variable name colors and display intensity"), false); +Configure variable name colors and display intensity"), + &style_set_list, &style_show_list, + false); - STYLE_ADD_SETSHOW_COMMANDS (address_style, - _("\ + address_style.add_setshow_commands (no_class, _("\ Address display styling.\n\ -Configure address colors and display intensity"), false); +Configure address colors and display intensity"), + &style_set_list, &style_show_list, + false); - STYLE_ADD_SETSHOW_COMMANDS (title_style, - _("\ + title_style.add_setshow_commands (no_class, _("\ Title display styling.\n\ Configure title colors and display intensity\n\ Some commands (such as \"apropos -v REGEXP\") use the title style to improve\n\ -readability."), false); +readability."), + &style_set_list, &style_show_list, + false); - STYLE_ADD_SETSHOW_COMMANDS (highlight_style, - _("\ + highlight_style.add_setshow_commands (no_class, _("\ Highlight display styling.\n\ Configure highlight colors and display intensity\n\ Some commands use the highlight style to draw the attention to a part\n\ -of their output."), false); +of their output."), + &style_set_list, &style_show_list, + false); - STYLE_ADD_SETSHOW_COMMANDS (metadata_style, - _("\ + metadata_style.add_setshow_commands (no_class, _("\ Metadata display styling.\n\ Configure metadata colors and display intensity\n\ The \"metadata\" style is used when GDB displays information about\n\ -your data, for example \"<unavailable>\""), false); +your data, for example \"<unavailable>\""), + &style_set_list, &style_show_list, + false); - STYLE_ADD_SETSHOW_COMMANDS (tui_border_style, - _("\ + tui_border_style.add_setshow_commands (no_class, _("\ TUI border display styling.\n\ Configure TUI border colors\n\ The \"tui-border\" style is used when GDB displays the border of a\n\ -TUI window that does not have the focus."), true); +TUI window that does not have the focus."), + &style_set_list, &style_show_list, + true); - STYLE_ADD_SETSHOW_COMMANDS (tui_active_border_style, - _("\ + tui_active_border_style.add_setshow_commands (no_class, _("\ TUI active border display styling.\n\ Configure TUI active border colors\n\ The \"tui-active-border\" style is used when GDB displays the border of a\n\ -TUI window that does have the focus."), true); +TUI window that does have the focus."), + &style_set_list, + &style_show_list, + true); } diff --git a/gdb/cli/cli-style.h b/gdb/cli/cli-style.h index 04009aa..6422e52 100644 --- a/gdb/cli/cli-style.h +++ b/gdb/cli/cli-style.h @@ -46,9 +46,7 @@ public: void add_setshow_commands (enum command_class theclass, const char *prefix_doc, struct cmd_list_element **set_list, - void (*do_set) (const char *args, int from_tty), struct cmd_list_element **show_list, - void (*do_show) (const char *args, int from_tty), bool skip_intensity); /* Return the 'set style NAME' command list, that can be used |