diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-09-22 13:43:25 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2021-10-28 10:44:18 -0400 |
commit | f54bdb6d2799c658e076f10e42222949dc51032d (patch) | |
tree | bd9804255bf472e93740a8b47b2f90d5bde939c3 /gdb/valprint.c | |
parent | 5ad2694b1ebe123ea92fcee094a69bcdc9769985 (diff) | |
download | gdb-f54bdb6d2799c658e076f10e42222949dc51032d.zip gdb-f54bdb6d2799c658e076f10e42222949dc51032d.tar.gz gdb-f54bdb6d2799c658e076f10e42222949dc51032d.tar.bz2 |
gdb: add add_setshow_prefix_cmd
There's a common pattern to call add_basic_prefix_cmd and
add_show_prefix_cmd to add matching set and show commands. Add the
add_setshow_prefix_cmd function to factor that out and use it at a few
places.
Change-Id: I6e9e90a30e9efb7b255bf839cac27b85d7069cfd
Diffstat (limited to 'gdb/valprint.c')
-rw-r--r-- | gdb/valprint.c | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/gdb/valprint.c b/gdb/valprint.c index 6eb3db2..e5afb3d 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -3173,33 +3173,26 @@ _initialize_valprint () selftests::register_test_foreach_arch ("print-flags", test_print_flags); #endif - cmd_list_element *cmd; - - 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); + set_show_commands setshow_print_cmds + = add_setshow_prefix_cmd ("print", no_class, + _("Generic command for setting how things print."), + _("Generic command for showing print settings."), + &setprintlist, &showprintlist, + &setlist, &showlist); + add_alias_cmd ("p", setshow_print_cmds.set, no_class, 1, &setlist); /* Prefer set print to set prompt. */ - 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, - _("\ -Generic command for setting what things to print in \"raw\" mode."), - &setprintrawlist, 0, &setprintlist); - deprecate_cmd (cmd, nullptr); - - cmd = add_show_prefix_cmd ("raw", no_class, - _("Generic command for showing \"print raw\" settings."), - &showprintrawlist, 0, &showprintlist); - deprecate_cmd (cmd, nullptr); + add_alias_cmd ("pr", setshow_print_cmds.set, no_class, 1, &setlist); + add_alias_cmd ("p", setshow_print_cmds.show, no_class, 1, &showlist); + add_alias_cmd ("pr", setshow_print_cmds.show, no_class, 1, &showlist); + + set_show_commands setshow_print_raw_cmds + = add_setshow_prefix_cmd + ("raw", no_class, + _("Generic command for setting what things to print in \"raw\" mode."), + _("Generic command for showing \"print raw\" settings."), + &setprintrawlist, &showprintrawlist, &setprintlist, &showprintlist); + deprecate_cmd (setshow_print_raw_cmds.set, nullptr); + deprecate_cmd (setshow_print_raw_cmds.show, nullptr); gdb::option::add_setshow_cmds_for_options (class_support, &user_print_options, value_print_option_defs, |