gdb: add add_setshow_prefix_cmd
authorSimon Marchi <simon.marchi@polymtl.ca>
Wed, 22 Sep 2021 17:43:25 +0000 (13:43 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Thu, 28 Oct 2021 14:44:18 +0000 (10:44 -0400)
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

34 files changed:
gdb/ada-lang.c
gdb/arm-tdep.c
gdb/breakpoint.c
gdb/btrace.c
gdb/cli/cli-cmds.c
gdb/cli/cli-decode.c
gdb/cli/cli-logging.c
gdb/cli/cli-style.c
gdb/command.h
gdb/dcache.c
gdb/dwarf2/read.c
gdb/f-lang.c
gdb/frame.c
gdb/guile/guile.c
gdb/i386-tdep.c
gdb/language.c
gdb/maint-test-settings.c
gdb/memattr.c
gdb/mips-tdep.c
gdb/python/python.c
gdb/ravenscar-thread.c
gdb/record-btrace.c
gdb/record-full.c
gdb/record.c
gdb/riscv-tdep.c
gdb/rs6000-tdep.c
gdb/ser-tcp.c
gdb/serial.c
gdb/sh-tdep.c
gdb/target-descriptions.c
gdb/tui/tui-win.c
gdb/typeprint.c
gdb/utils.c
gdb/valprint.c

index b0c915fcc46ab70fbd1818f17aa702bb60c41b5a..d7e78729e2f8268e049708eef8bc49d86e87cfa5 100644 (file)
@@ -13508,13 +13508,12 @@ _initialize_ada_language ()
 {
   initialize_ada_catchpoint_ops ();
 
-  add_basic_prefix_cmd ("ada", no_class,
-                       _("Prefix command for changing Ada-specific settings."),
-                       &set_ada_list, 0, &setlist);
-
-  add_show_prefix_cmd ("ada", no_class,
-                      _("Generic command for showing Ada-specific settings."),
-                      &show_ada_list, 0, &showlist);
+  add_setshow_prefix_cmd
+    ("ada", no_class,
+     _("Prefix command for changing Ada-specific settings."),
+     _("Generic command for showing Ada-specific settings."),
+     &set_ada_list, &show_ada_list,
+     &setlist, &showlist);
 
   add_setshow_boolean_cmd ("trust-PAD-over-XVS", class_obscure,
                           &trust_pad_over_xvs, _("\
@@ -13582,15 +13581,11 @@ Usage: info exceptions [REGEXP]\n\
 If a regular expression is passed as an argument, only those matching\n\
 the regular expression are listed."));
 
-  add_basic_prefix_cmd ("ada", class_maintenance,
-                       _("Set Ada maintenance-related variables."),
-                       &maint_set_ada_cmdlist,
-                       0/*allow-unknown*/, &maintenance_set_cmdlist);
-
-  add_show_prefix_cmd ("ada", class_maintenance,
-                      _("Show Ada maintenance-related variables."),
-                      &maint_show_ada_cmdlist,
-                      0/*allow-unknown*/, &maintenance_show_cmdlist);
+  add_setshow_prefix_cmd ("ada", class_maintenance,
+                         _("Set Ada maintenance-related variables."),
+                         _("Show Ada maintenance-related variables."),
+                         &maint_set_ada_cmdlist, &maint_show_ada_cmdlist,
+                         &maintenance_set_cmdlist, &maintenance_show_cmdlist);
 
   add_setshow_boolean_cmd
     ("ignore-descriptive-types", class_maintenance,
index 768844dd6c918334540ff59430034c74e1999db5..10f8e00d6c30b6e6093533f654c427c83c7e6975 100644 (file)
@@ -9759,14 +9759,11 @@ _initialize_arm_tdep ()
                                  arm_elf_osabi_sniffer);
 
   /* Add root prefix command for all "set arm"/"show arm" commands.  */
-  add_basic_prefix_cmd ("arm", no_class,
-                       _("Various ARM-specific commands."),
-                       &setarmcmdlist, 0, &setlist);
-
-  add_show_prefix_cmd ("arm", no_class,
-                      _("Various ARM-specific commands."),
-                      &showarmcmdlist, 0, &showlist);
-
+  add_setshow_prefix_cmd ("arm", no_class,
+                         _("Various ARM-specific commands."),
+                         _("Various ARM-specific commands."),
+                         &setarmcmdlist, &showarmcmdlist,
+                         &setlist, &showlist);
 
   arm_disassembler_options = xstrdup ("reg-names-std");
   const disasm_options_t *disasm_options
index de96f911900cd14a49643cf844f2e66e5dcbabe9..4ec60f334a2f0c1f2d02a04c65e71a8bf7585298 100644 (file)
@@ -15881,18 +15881,17 @@ Use the 'source' command in another debug session to restore them."),
   c = add_com_alias ("save-tracepoints", save_tracepoints_cmd, class_trace, 0);
   deprecate_cmd (c, "save tracepoints");
 
-  add_basic_prefix_cmd ("breakpoint", class_maintenance, _("\
+  add_setshow_prefix_cmd ("breakpoint", class_maintenance,
+                         _("\
 Breakpoint specific settings.\n\
 Configure various breakpoint-specific variables such as\n\
 pending breakpoint behavior."),
-                       &breakpoint_set_cmdlist,
-                       0/*allow-unknown*/, &setlist);
-  add_show_prefix_cmd ("breakpoint", class_maintenance, _("\
+                         _("\
 Breakpoint specific settings.\n\
 Configure various breakpoint-specific variables such as\n\
 pending breakpoint behavior."),
-                      &breakpoint_show_cmdlist,
-                      0/*allow-unknown*/, &showlist);
+                         &breakpoint_set_cmdlist, &breakpoint_show_cmdlist,
+                         &setlist, &showlist);
 
   add_setshow_auto_boolean_cmd ("pending", no_class,
                                &pending_break_support, _("\
index 6a7b4cfcfc0da03196f94eec09b3826e4f2ccea8..f12b1554d65f1f6572ca43e31f598d4defa2b664 100644 (file)
@@ -3455,25 +3455,21 @@ _initialize_btrace ()
                        _("Branch tracing maintenance commands."),
                        &maint_btrace_cmdlist, 0, &maintenancelist);
 
-  add_basic_prefix_cmd ("btrace", class_maintenance, _("\
-Set branch tracing specific variables."),
-                       &maint_btrace_set_cmdlist,
-                       0, &maintenance_set_cmdlist);
-
-  add_basic_prefix_cmd ("pt", class_maintenance, _("\
-Set Intel Processor Trace specific variables."),
-                       &maint_btrace_pt_set_cmdlist,
-                       0, &maint_btrace_set_cmdlist);
-
-  add_show_prefix_cmd ("btrace", class_maintenance, _("\
-Show branch tracing specific variables."),
-                      &maint_btrace_show_cmdlist,
-                      0, &maintenance_show_cmdlist);
-
-  add_show_prefix_cmd ("pt", class_maintenance, _("\
-Show Intel Processor Trace specific variables."),
-                      &maint_btrace_pt_show_cmdlist,
-                      0, &maint_btrace_show_cmdlist);
+  add_setshow_prefix_cmd ("btrace", class_maintenance,
+                         _("Set branch tracing specific variables."),
+                         _("Show branch tracing specific variables."),
+                         &maint_btrace_set_cmdlist,
+                         &maint_btrace_show_cmdlist,
+                         &maintenance_set_cmdlist,
+                         &maintenance_show_cmdlist);
+
+  add_setshow_prefix_cmd ("pt", class_maintenance,
+                         _("Set Intel Processor Trace specific variables."),
+                         _("Show Intel Processor Trace specific variables."),
+                         &maint_btrace_pt_set_cmdlist,
+                         &maint_btrace_pt_show_cmdlist,
+                         &maint_btrace_set_cmdlist,
+                         &maint_btrace_show_cmdlist);
 
   add_setshow_boolean_cmd ("skip-pad", class_maintenance,
                           &maint_btrace_pt_skip_pad, _("\
index 9b77409b86f6f06f1c4f13742112fbc8a935cb38..2cf614c8e7ecafd83b3aa68ea85bfdfb5624b5b7 100644 (file)
@@ -2394,12 +2394,11 @@ Show verbosity."), NULL,
                           show_info_verbose,
                           &setlist, &showlist);
 
-  add_basic_prefix_cmd ("history", class_support, _("\
-Generic command for setting command history parameters."),
-                       &sethistlist, 0, &setlist);
-  add_show_prefix_cmd ("history", class_support, _("\
-Generic command for showing command history parameters."),
-                      &showhistlist, 0, &showlist);
+  add_setshow_prefix_cmd
+    ("history", class_support,
+     _("Generic command for setting command history parameters."),
+     _("Generic command for showing command history parameters."),
+     &sethistlist, &showhistlist, &setlist, &showlist);
 
   add_setshow_boolean_cmd ("expansion", no_class, &history_expansion_p, _("\
 Set history expansion on command input."), _("\
@@ -2493,13 +2492,11 @@ the previous command number shown."),
   add_cmd ("configuration", no_set_class, show_configuration,
           _("Show how GDB was configured at build time."), &showlist);
 
-  add_basic_prefix_cmd ("debug", no_class,
-                       _("Generic command for setting gdb debugging flags."),
-                       &setdebuglist, 0, &setlist);
-
-  add_show_prefix_cmd ("debug", no_class,
-                      _("Generic command for showing gdb debugging flags."),
-                      &showdebuglist, 0, &showlist);
+  add_setshow_prefix_cmd ("debug", no_class,
+                         _("Generic command for setting gdb debugging flags."),
+                         _("Generic command for showing gdb debugging flags."),
+                         &setdebuglist, &showdebuglist,
+                         &setlist, &showlist);
 
   cmd_list_element *shell_cmd
     = add_com ("shell", class_support, shell_command, _("\
index 3b0830e4c17f9c005b339de2a8dea12a5b5d9955..27a80192c48529fe02d85c15ca5a11ac361a98de 100644 (file)
@@ -407,6 +407,28 @@ add_show_prefix_cmd (const char *name, enum command_class theclass,
   return cmd;
 }
 
+/* See command.h.  */
+
+set_show_commands
+add_setshow_prefix_cmd (const char *name, command_class theclass,
+                       const char *set_doc, const char *show_doc,
+                       cmd_list_element **set_subcommands_list,
+                       cmd_list_element **show_subcommands_list,
+                       cmd_list_element **set_list,
+                       cmd_list_element **show_list)
+{
+  set_show_commands cmds;
+
+  cmds.set = add_basic_prefix_cmd (name, theclass, set_doc,
+                                  set_subcommands_list, 0,
+                                  set_list);
+  cmds.show = add_show_prefix_cmd (name, theclass, show_doc,
+                                  show_subcommands_list, 0,
+                                  show_list);
+
+  return cmds;
+}
+
 /* Like ADD_PREFIX_CMD but sets the suppress_notification pointer on the
    new command list element.  */
 
index c9093520a71bd310759ff640116508fc3772450c..f0ee09180f9ace9c7ad2d0a64804c2622e75d404 100644 (file)
@@ -169,12 +169,12 @@ _initialize_cli_logging ()
 {
   static struct cmd_list_element *set_logging_cmdlist, *show_logging_cmdlist;
 
-  add_basic_prefix_cmd ("logging", class_support,
-                       _("Set logging options."), &set_logging_cmdlist,
-                       0, &setlist);
-  add_show_prefix_cmd ("logging", class_support,
-                      _("Show logging options."), &show_logging_cmdlist,
-                      0, &showlist);
+  add_setshow_prefix_cmd ("logging", class_support,
+                         _("Set logging options."),
+                         _("Show logging options."),
+                         &set_logging_cmdlist, &show_logging_cmdlist,
+                         &setlist, &showlist);
+
   add_setshow_boolean_cmd ("overwrite", class_support, &logging_overwrite, _("\
 Set whether logging overwrites or appends to the log file."), _("\
 Show whether logging overwrites or appends to the log file."), _("\
index aca19c51b848a2ec094ba8a0a9cd43059d11b7b9..f7e1a844ec08b869f5965e3e70b633a6c683463d 100644 (file)
@@ -226,10 +226,9 @@ cli_style_option::add_setshow_commands (enum command_class theclass,
                                        struct cmd_list_element **show_list,
                                        bool skip_intensity)
 {
-  add_basic_prefix_cmd (m_name, no_class, prefix_doc, &m_set_list,
-                       0, set_list);
-  add_show_prefix_cmd (m_name, no_class, prefix_doc, &m_show_list,
-                      0, show_list);
+  add_setshow_prefix_cmd (m_name, theclass, prefix_doc, prefix_doc,
+                         &m_set_list, &m_show_list, set_list, show_list);
+
   set_show_commands commands;
 
   commands = add_setshow_enum_cmd
@@ -306,14 +305,15 @@ void _initialize_cli_style ();
 void
 _initialize_cli_style ()
 {
-  add_basic_prefix_cmd ("style", no_class, _("\
+  add_setshow_prefix_cmd ("style", no_class,
+                         _("\
 Style-specific settings.\n\
 Configure various style-related variables, such as colors"),
-                 &style_set_list, 0, &setlist);
-  add_show_prefix_cmd ("style", no_class, _("\
+                         _("\
 Style-specific settings.\n\
 Configure various style-related variables, such as colors"),
-                 &style_show_list, 0, &showlist);
+                         &style_set_list, &style_show_list,
+                         &setlist, &showlist);
 
   add_setshow_boolean_cmd ("enabled", no_class, &cli_styling, _("\
 Set whether CLI styling is enabled."), _("\
index 0049ab6ff9e0dc5da5265d38991604b2d65a6d6f..9afe70cf66a61341b535db096a6e24a73ad782d1 100644 (file)
@@ -382,6 +382,13 @@ extern bool valid_user_defined_cmd_name_p (const char *name);
 
 extern bool valid_cmd_char_p (int c);
 
+/* Return value type for the add_setshow_* functions.  */
+
+struct set_show_commands
+{
+  cmd_list_element *set, *show;
+};
+
 /* Const-correct variant of the above.  */
 
 extern struct cmd_list_element *add_cmd (const char *, enum command_class,
@@ -428,6 +435,17 @@ extern struct cmd_list_element *add_show_prefix_cmd
   (const char *, enum command_class, const char *, struct cmd_list_element **,
    int, struct cmd_list_element **);
 
+/* Add matching set and show commands using add_basic_prefix_cmd and
+   add_show_prefix_cmd.  */
+
+extern set_show_commands add_setshow_prefix_cmd
+  (const char *name, command_class theclass, const char *set_doc,
+   const char *show_doc,
+   cmd_list_element **set_subcommands_list,
+   cmd_list_element **show_subcommands_list,
+   cmd_list_element **set_list,
+   cmd_list_element **show_list);
+
 extern struct cmd_list_element *add_prefix_cmd_suppress_notification
                        (const char *name, enum command_class theclass,
                         cmd_simple_func_ftype *fun,
@@ -616,13 +634,6 @@ typedef void (show_value_ftype) (struct ui_file *file,
    instead print the value out directly.  */
 extern show_value_ftype deprecated_show_value_hack;
 
-/* Return value type for the add_setshow_* functions.  */
-
-struct set_show_commands
-{
-  cmd_list_element *set, *show;
-};
-
 extern set_show_commands add_setshow_enum_cmd
   (const char *name, command_class theclass, const char *const *enumlist,
    const char **var, const char *set_doc, const char *show_doc,
index 98365fee3b1cabb8cbed8651f2015238809eadca..eed185146a7a91436e95a454c835955f3b7be22e 100644 (file)
@@ -702,13 +702,12 @@ With no arguments, this command prints the cache configuration and a\n\
 summary of each line in the cache.  With an argument, dump\"\n\
 the contents of the given line."));
 
-  add_basic_prefix_cmd ("dcache", class_obscure, _("\
+  add_setshow_prefix_cmd ("dcache", class_obscure,
+                         _("\
 Use this command to set number of lines in dcache and line-size."),
-                       &dcache_set_list, /*allow_unknown*/0, &setlist);
-  add_show_prefix_cmd ("dcache", class_obscure, _("\
-Show dcachesettings."),
-                      &dcache_show_list, /*allow_unknown*/0,
-                      &showlist);
+                         ("Show dcache settings."),
+                         &dcache_set_list, &dcache_show_list,
+                         &setlist, &showlist);
 
   add_setshow_zuinteger_cmd ("line-size", class_obscure,
                             &dcache_line_size, _("\
index af184d4d1fd481188ef78496857fafd5cd5ef109..8b223e49af7c2a2c5e0bab00774a924a457ab176 100644 (file)
@@ -24889,17 +24889,15 @@ void _initialize_dwarf2_read ();
 void
 _initialize_dwarf2_read ()
 {
-  add_basic_prefix_cmd ("dwarf", class_maintenance, _("\
+  add_setshow_prefix_cmd ("dwarf", class_maintenance,
+                         _("\
 Set DWARF specific variables.\n\
 Configure DWARF variables such as the cache size."),
-                       &set_dwarf_cmdlist,
-                       0/*allow-unknown*/, &maintenance_set_cmdlist);
-
-  add_show_prefix_cmd ("dwarf", class_maintenance, _("\
+                         _("\
 Show DWARF specific variables.\n\
 Show DWARF variables such as the cache size."),
-                      &show_dwarf_cmdlist,
-                      0/*allow-unknown*/, &maintenance_show_cmdlist);
+                         &set_dwarf_cmdlist, &show_dwarf_cmdlist,
+                         &maintenance_set_cmdlist, &maintenance_show_cmdlist);
 
   add_setshow_zinteger_cmd ("max-cache-age", class_obscure,
                            &dwarf_max_cache_age, _("\
index 1b5a99c5961cfb83e9010ba17e97d1f36bca91fc..230feb78e26ca07d741fc6455af7ae40ae5447f5 100644 (file)
@@ -1681,13 +1681,12 @@ _initialize_f_language ()
 {
   f_type_data = gdbarch_data_register_post_init (build_fortran_types);
 
-  add_basic_prefix_cmd ("fortran", no_class,
-                       _("Prefix command for changing Fortran-specific settings."),
-                       &set_fortran_list, 0, &setlist);
-
-  add_show_prefix_cmd ("fortran", no_class,
-                      _("Generic command for showing Fortran-specific settings."),
-                      &show_fortran_list, 0, &showlist);
+  add_setshow_prefix_cmd
+    ("fortran", no_class,
+     _("Prefix command for changing Fortran-specific settings."),
+     _("Generic command for showing Fortran-specific settings."),
+     &set_fortran_list, &show_fortran_list,
+     &setlist, &showlist);
 
   add_setshow_boolean_cmd ("repack-array-slices", class_vars,
                           &repack_array_slices, _("\
index b121892f799a5f0d2089ce5df43087f608d87a17..2a899fc494f247d895389fc43c3ae5599a7646c9 100644 (file)
@@ -3129,16 +3129,15 @@ _initialize_frame ()
   gdb::observers::target_changed.attach (frame_observer_target_changed,
                                         "frame");
 
-  add_basic_prefix_cmd ("backtrace", class_maintenance, _("\
+  add_setshow_prefix_cmd ("backtrace", class_maintenance,
+                         _("\
 Set backtrace specific variables.\n\
 Configure backtrace variables such as the backtrace limit"),
-                       &set_backtrace_cmdlist,
-                       0/*allow-unknown*/, &setlist);
-  add_show_prefix_cmd ("backtrace", class_maintenance, _("\
+                         _("\
 Show backtrace specific variables.\n\
 Show backtrace variables such as the backtrace limit."),
-                      &show_backtrace_cmdlist,
-                      0/*allow-unknown*/, &showlist);
+                         &set_backtrace_cmdlist, &show_backtrace_cmdlist,
+                         &setlist, &showlist);
 
   add_setshow_uinteger_cmd ("limit", class_obscure,
                            &user_set_backtrace_options.backtrace_limit, _("\
index 8ba840cba6a86e29524bb41b7ef1558aff794c15..30cfa296fc5926a1bcdac1ae3d5d08a0993dbec9 100644 (file)
@@ -780,17 +780,17 @@ This command is only a placeholder.")
           );
   add_com_alias ("gu", guile_cmd_element, class_obscure, 1);
 
-  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);
+  set_show_commands setshow_guile_cmds
+    = add_setshow_prefix_cmd ("guile", class_obscure,
+                             _("\
+Prefix command for Guile preference settings."),
+                             _("\
+Prefix command for Guile preference settings."),
+                             &set_guile_list, &show_guile_list,
+                             &setlist, &showlist);
+
+  add_alias_cmd ("gu", setshow_guile_cmds.set, class_obscure, 1, &setlist);
+  add_alias_cmd ("gu", setshow_guile_cmds.show, class_obscure, 1, &showlist);
 
   cmd_list_element *info_guile_cmd
     = add_basic_prefix_cmd ("guile", class_obscure,
index 23dc39a900de31ff9a1ec12f746c58125734b58d..f65a07492d2f2d404213aab04d4614c3f71d776b 100644 (file)
@@ -9043,19 +9043,13 @@ is \"default\"."),
                        NULL, /* FIXME: i18n: */
                        &setlist, &showlist);
 
-  /* Add "mpx" prefix for the set commands.  */
+  /* Add "mpx" prefix for the set and show commands.  */
 
-  add_basic_prefix_cmd ("mpx", class_support, _("\
-Set Intel Memory Protection Extensions specific variables."),
-                       &mpx_set_cmdlist,
-                       0 /* allow-unknown */, &setlist);
-
-  /* Add "mpx" prefix for the show commands.  */
-
-  add_show_prefix_cmd ("mpx", class_support, _("\
-Show Intel Memory Protection Extensions specific variables."),
-                      &mpx_show_cmdlist,
-                      0 /* allow-unknown */, &showlist);
+  add_setshow_prefix_cmd
+    ("mpx", class_support,
+     _("Set Intel Memory Protection Extensions specific variables."),
+     _("Show Intel Memory Protection Extensions specific variables."),
+     &mpx_set_cmdlist, &mpx_show_cmdlist, &setlist, &showlist);
 
   /* Add "bound" command for the show mpx commands list.  */
 
index 81bc2a5a8c6e7f0103fc098fb93c889da02b6920..9ac48a494c99a3ababe031783fa9a913323ebcf6 100644 (file)
@@ -1140,19 +1140,16 @@ _initialize_language ()
 
   /* GDB commands for language specific stuff.  */
 
-  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);
+  set_show_commands setshow_check_cmds
+    = add_setshow_prefix_cmd ("check", no_class,
+                             _("Set the status of the type/range checker."),
+                             _("Show the status of the type/range checker."),
+                             &setchecklist, &showchecklist,
+                             &setlist, &showlist);
+  add_alias_cmd ("c", setshow_check_cmds.set, no_class, 1, &setlist);
+  add_alias_cmd ("ch", setshow_check_cmds.set, no_class, 1, &setlist);
+  add_alias_cmd ("c", setshow_check_cmds.show, no_class, 1, &showlist);
+  add_alias_cmd ("ch", setshow_check_cmds.show, no_class, 1, &showlist);
 
   add_setshow_enum_cmd ("range", class_support, type_or_range_names,
                        &range,
index eea3ea9957267c94e9ff68069ef9ffd461dab544..9f50088833ab147d0f7d912f4c84eaf9d6329a51 100644 (file)
@@ -85,19 +85,14 @@ _initialize_maint_test_settings ()
 {
   maintenance_test_settings_filename = xstrdup ("/foo/bar");
 
-  add_basic_prefix_cmd ("test-settings", class_maintenance,
-                       _("\
+  add_setshow_prefix_cmd ("test-settings", class_maintenance,
+                         _("\
 Set GDB internal variables used for set/show command infrastructure testing."),
-                       &maintenance_set_test_settings_list,
-                       0/*allow-unknown*/,
-                       &maintenance_set_cmdlist);
-
-  add_show_prefix_cmd ("test-settings", class_maintenance,
-                      _("\
+                         _("\
 Show GDB internal variables used for set/show command infrastructure testing."),
-                      &maintenance_show_test_settings_list,
-                      0/*allow-unknown*/,
-                      &maintenance_show_cmdlist);
+                         &maintenance_set_test_settings_list,
+                         &maintenance_show_test_settings_list,
+                         &maintenance_set_cmdlist, &maintenance_show_cmdlist);
 
   add_setshow_boolean_cmd ("boolean", class_maintenance,
                           &maintenance_test_settings_boolean, _("\
index e1c3931c26291c91f21db561f7c2bfeda18a9b21..c163ac07ebeb918545ea78e8e080e4a29a7ab929 100644 (file)
@@ -623,14 +623,11 @@ Do \"info mem\" to see current list of IDs."), &deletelist);
   add_info ("mem", info_mem_command,
            _("Memory region attributes."));
 
-  add_basic_prefix_cmd ("mem", class_vars, _("\
-Memory regions settings."),
-                       &mem_set_cmdlist,
-                       0/* allow-unknown */, &setlist);
-  add_show_prefix_cmd ("mem", class_vars, _("\
-Memory regions settings."),
-                      &mem_show_cmdlist,
-                      0/* allow-unknown */, &showlist);
+  add_setshow_prefix_cmd ("mem", class_vars,
+                         _("Memory regions settings."),
+                         _("Memory regions settings."),
+                         &mem_set_cmdlist, &mem_show_cmdlist,
+                         &setlist, &showlist);
 
   add_setshow_boolean_cmd ("inaccessible-by-default", no_class,
                                  &inaccessible_by_default, _("\
index 57295d6fd1a8c11f00b78911d6f844182d05ec74..d9f8652009b09dfdf161eaadd4232b7b4de04856 100644 (file)
@@ -8942,13 +8942,11 @@ _initialize_mips_tdep ()
   set_tdesc_property (mips_tdesc_gp64, PROPERTY_GP64, "");
 
   /* Add root prefix command for all "set mips"/"show mips" commands.  */
-  add_basic_prefix_cmd ("mips", no_class,
-                       _("Various MIPS specific commands."),
-                       &setmipscmdlist, 0, &setlist);
-
-  add_show_prefix_cmd ("mips", no_class,
-                      _("Various MIPS specific commands."),
-                      &showmipscmdlist, 0, &showlist);
+  add_setshow_prefix_cmd ("mips", no_class,
+                         _("Various MIPS specific commands."),
+                         _("Various MIPS specific commands."),
+                         &setmipscmdlist, &showmipscmdlist,
+                         &setlist, &showlist);
 
   /* Allow the user to override the ABI.  */
   add_setshow_enum_cmd ("abi", class_obscure, mips_abi_strings,
index c81814c557be84990a1ce101294a9b19e211957b..593fbc1be7a148a733a66cce88b42f7b2f1d6fb0 100644 (file)
@@ -2041,13 +2041,11 @@ This command is only a placeholder.")
   add_com_alias ("py", python_cmd_element, class_obscure, 1);
 
   /* Add set/show python print-stack.  */
-  add_basic_prefix_cmd ("python", no_class,
-                       _("Prefix command for python preference settings."),
-                       &user_show_python_list, 0, &showlist);
-
-  add_show_prefix_cmd ("python", no_class,
-                      _("Prefix command for python preference settings."),
-                      &user_set_python_list, 0, &setlist);
+  add_setshow_prefix_cmd ("python", no_class,
+                         _("Prefix command for python preference settings."),
+                         _("Prefix command for python preference settings."),
+                         &user_set_python_list, &user_show_python_list,
+                         &setlist, &showlist);
 
   add_setshow_enum_cmd ("print-stack", no_class, python_excp_enums,
                        &gdbpy_should_print_stack, _("\
index 4afe95cb96b538ecf9fd6057ed22f6b184b04d9c..0611fa8b4f1bd18b2a46338005618f95a533a4d6 100644 (file)
@@ -718,13 +718,12 @@ _initialize_ravenscar ()
   gdb::observers::inferior_created.attach (ravenscar_inferior_created,
                                           "ravenscar-thread");
 
-  add_basic_prefix_cmd ("ravenscar", no_class,
-                       _("Prefix command for changing Ravenscar-specific settings."),
-                       &set_ravenscar_list, 0, &setlist);
-
-  add_show_prefix_cmd ("ravenscar", no_class,
-                      _("Prefix command for showing Ravenscar-specific settings."),
-                      &show_ravenscar_list, 0, &showlist);
+  add_setshow_prefix_cmd
+    ("ravenscar", no_class,
+     _("Prefix command for changing Ravenscar-specific settings."),
+     _("Prefix command for showing Ravenscar-specific settings."),
+     &set_ravenscar_list, &show_ravenscar_list,
+     &setlist, &showlist);
 
   add_setshow_boolean_cmd ("task-switching", class_obscure,
                           &ravenscar_task_support, _("\
index e2538ee8edae484201427ade04db5b5f25160c3e..a9518d57bcb106fa92d8a56cc82a6b065346a715 100644 (file)
@@ -3132,13 +3132,12 @@ This format may not be available on all processors."),
             &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,
-                       0, &set_record_cmdlist);
-
-  add_show_prefix_cmd ("btrace", class_support,
-                      _("Show record options."), &show_record_btrace_cmdlist,
-                      0, &show_record_cmdlist);
+  add_setshow_prefix_cmd ("btrace", class_support,
+                         _("Set record options."),
+                         _("Show record options."),
+                         &set_record_btrace_cmdlist,
+                         &show_record_btrace_cmdlist,
+                         &set_record_cmdlist, &show_record_cmdlist);
 
   add_setshow_enum_cmd ("replay-memory-access", no_class,
                        replay_memory_access_types, &replay_memory_access, _("\
@@ -3181,17 +3180,13 @@ Do not enable errata workarounds for trace decode."),
 Show the cpu to be used for trace decode."),
           &show_record_btrace_cmdlist);
 
-  add_basic_prefix_cmd ("bts", class_support,
-                       _("Set record btrace bts options."),
-                       &set_record_btrace_bts_cmdlist,
-                       0,
-                       &set_record_btrace_cmdlist);
-
-  add_show_prefix_cmd ("bts", class_support,
-                      _("Show record btrace bts options."),
-                      &show_record_btrace_bts_cmdlist,
-                      0,
-                      &show_record_btrace_cmdlist);
+  add_setshow_prefix_cmd ("bts", class_support,
+                         _("Set record btrace bts options."),
+                         _("Show record btrace bts options."),
+                         &set_record_btrace_bts_cmdlist,
+                         &show_record_btrace_bts_cmdlist,
+                         &set_record_btrace_cmdlist,
+                         &show_record_btrace_cmdlist);
 
   add_setshow_uinteger_cmd ("buffer-size", no_class,
                            &record_btrace_conf.bts.size,
@@ -3207,17 +3202,13 @@ The trace buffer size may not be changed while recording."), NULL,
                            &set_record_btrace_bts_cmdlist,
                            &show_record_btrace_bts_cmdlist);
 
-  add_basic_prefix_cmd ("pt", class_support,
-                       _("Set record btrace pt options."),
-                       &set_record_btrace_pt_cmdlist,
-                       0,
-                       &set_record_btrace_cmdlist);
-
-  add_show_prefix_cmd ("pt", class_support,
-                      _("Show record btrace pt options."),
-                      &show_record_btrace_pt_cmdlist,
-                      0,
-                      &show_record_btrace_cmdlist);
+  add_setshow_prefix_cmd ("pt", class_support,
+                         _("Set record btrace pt options."),
+                         _("Show record btrace pt options."),
+                         &set_record_btrace_pt_cmdlist,
+                         &show_record_btrace_pt_cmdlist,
+                         &set_record_btrace_cmdlist,
+                         &show_record_btrace_cmdlist);
 
   add_setshow_uinteger_cmd ("buffer-size", no_class,
                            &record_btrace_conf.pt.size,
index bb02e766748d3dc6168b90fe9319be6e30f7ad16..971c0f568b4d99397069f2169ef6499094b45dec 100644 (file)
@@ -2804,13 +2804,13 @@ Argument is filename.  File must be created with 'record save'."),
   set_cmd_completer (c, filename_completer);
   deprecate_cmd (c, "record full restore");
 
-  add_basic_prefix_cmd ("full", class_support,
-                       _("Set record options."), &set_record_full_cmdlist,
-                       0, &set_record_cmdlist);
-
-  add_show_prefix_cmd ("full", class_support,
-                      _("Show record options."), &show_record_full_cmdlist,
-                      0, &show_record_cmdlist);
+  add_setshow_prefix_cmd ("full", class_support,
+                         _("Set record options."),
+                         _("Show record options."),
+                         &set_record_full_cmdlist,
+                         &show_record_full_cmdlist,
+                         &set_record_cmdlist,
+                         &show_record_cmdlist);
 
   /* Record instructions number limit command.  */
   set_show_commands set_record_full_stop_at_limit_cmds
index 6968c30d930dbc0f029b10755dd7a79efc248152..37619780d37dfb97710d3556f0bed24e1b1ee015 100644 (file)
@@ -793,17 +793,16 @@ A size of \"unlimited\" means unlimited lines.  The default is 10."),
 
   add_com_alias ("rec", record_cmd, class_obscure, 1);
 
-  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);
+  set_show_commands setshow_record_cmds
+    = add_setshow_prefix_cmd ("record", class_support,
+                             _("Set record options."),
+                             _("Show record options."),
+                             &set_record_cmdlist, &show_record_cmdlist,
+                             &setlist, &showlist);
+
+
+  add_alias_cmd ("rec", setshow_record_cmds.set, class_obscure, 1, &setlist);
+  add_alias_cmd ("rec", setshow_record_cmds.show, class_obscure, 1, &showlist);
 
   cmd_list_element *info_record_cmd
     = add_prefix_cmd ("record", class_support, info_record_command,
index 4b92754f4cd7730bdf41f0f275615215bc16a5bb..4c2557f4dad2d30bbd4b91a71ce65b8606c4ca4a 100644 (file)
@@ -4018,15 +4018,11 @@ _initialize_riscv_tdep ()
 
   /* Add root prefix command for all "set debug riscv" and "show debug
      riscv" commands.  */
-  add_basic_prefix_cmd ("riscv", no_class,
-                       _("RISC-V specific debug commands."),
-                       &setdebugriscvcmdlist, 0,
-                       &setdebuglist);
-
-  add_show_prefix_cmd ("riscv", no_class,
-                      _("RISC-V specific debug commands."),
-                      &showdebugriscvcmdlist, 0,
-                      &showdebuglist);
+  add_setshow_prefix_cmd ("riscv", no_class,
+                         _("RISC-V specific debug commands."),
+                         _("RISC-V specific debug commands."),
+                         &setdebugriscvcmdlist, &showdebugriscvcmdlist,
+                         &setdebuglist, &showdebuglist);
 
   add_setshow_zuinteger_cmd ("breakpoints", class_maintenance,
                             &riscv_debug_breakpoints,  _("\
@@ -4069,13 +4065,11 @@ initialisation process."),
                             &setdebugriscvcmdlist, &showdebugriscvcmdlist);
 
   /* Add root prefix command for all "set riscv" and "show riscv" commands.  */
-  add_basic_prefix_cmd ("riscv", no_class,
-                       _("RISC-V specific commands."),
-                       &setriscvcmdlist, 0, &setlist);
-
-  add_show_prefix_cmd ("riscv", no_class,
-                      _("RISC-V specific commands."),
-                      &showriscvcmdlist, 0, &showlist);
+  add_setshow_prefix_cmd ("riscv", no_class,
+                         _("RISC-V specific commands."),
+                         _("RISC-V specific commands."),
+                         &setriscvcmdlist, &showriscvcmdlist,
+                         &setlist, &showlist);
 
 
   use_compressed_breakpoints = AUTO_BOOLEAN_AUTO;
index 9c2bfca3e9c3277c3d17e52be457a9a2491244ad..78b4fd1a9130ab4daa85d80c9e189c0e3b21d8dd 100644 (file)
@@ -7411,13 +7411,11 @@ _initialize_rs6000_tdep ()
 
   /* Add root prefix command for all "set powerpc"/"show powerpc"
      commands.  */
-  add_basic_prefix_cmd ("powerpc", no_class,
-                       _("Various PowerPC-specific commands."),
-                       &setpowerpccmdlist, 0, &setlist);
-
-  add_show_prefix_cmd ("powerpc", no_class,
-                      _("Various PowerPC-specific commands."),
-                      &showpowerpccmdlist, 0, &showlist);
+  add_setshow_prefix_cmd ("powerpc", no_class,
+                         _("Various PowerPC-specific commands."),
+                         _("Various PowerPC-specific commands."),
+                         &setpowerpccmdlist, &showpowerpccmdlist,
+                         &setlist, &showlist);
 
   /* Add a command to allow the user to force the ABI.  */
   add_setshow_auto_boolean_cmd ("soft-float", class_support,
index 2519caa505c0512768a51eea0052d4127b334598..7ed61db577499759a6b2f3afdebc64addd05c8e7 100644 (file)
@@ -466,16 +466,15 @@ _initialize_ser_tcp ()
   serial_add_interface (&tcp_ops);
 #endif /* USE_WIN32API */
 
-  add_basic_prefix_cmd ("tcp", class_maintenance, _("\
+  add_setshow_prefix_cmd ("tcp", class_maintenance,
+                         _("\
 TCP protocol specific variables.\n\
 Configure variables specific to remote TCP connections."),
-                       &tcp_set_cmdlist,
-                       0 /* allow-unknown */, &setlist);
-  add_show_prefix_cmd ("tcp", class_maintenance, _("\
+                         _("\
 TCP protocol specific variables.\n\
 Configure variables specific to remote TCP connections."),
-                      &tcp_show_cmdlist,
-                      0 /* allow-unknown */, &showlist);
+                         &tcp_set_cmdlist, &tcp_show_cmdlist,
+                         &setlist, &showlist);
 
   add_setshow_boolean_cmd ("auto-retry", class_obscure,
                           &tcp_auto_retry, _("\
index 5ec79a11aac42a865176f152df628b9f20b1bfbf..f85455dabcdf2ff5defcc8eacdc52fe5515a2ef2 100644 (file)
@@ -669,17 +669,11 @@ Connect the terminal directly up to the command monitor.\n\
 Use <CR>~. or <CR>~^D to break out."));
 #endif /* 0 */
 
-  add_basic_prefix_cmd ("serial", class_maintenance, _("\
-Set default serial/parallel port configuration."),
-                       &serial_set_cmdlist,
-                       0/*allow-unknown*/,
-                       &setlist);
-
-  add_show_prefix_cmd ("serial", class_maintenance, _("\
-Show default serial/parallel port configuration."),
-                      &serial_show_cmdlist,
-                      0/*allow-unknown*/,
-                      &showlist);
+  add_setshow_prefix_cmd ("serial", class_maintenance,
+                         _("Set default serial/parallel port configuration."),
+                         _("Show default serial/parallel port configuration."),
+                         &serial_set_cmdlist, &serial_show_cmdlist,
+                         &setlist, &showlist);
 
   /* If target is open when baud changes, it doesn't take effect until
      the next open (I think, not sure).  */
index 04431df3408e5640dcb8b9a924a43b816d09dbcc..f78eb2d73be50074d7dd32bad5643ddb65f623af 100644 (file)
@@ -2416,10 +2416,11 @@ _initialize_sh_tdep ()
 {
   gdbarch_register (bfd_arch_sh, sh_gdbarch_init, NULL);
 
-  add_basic_prefix_cmd ("sh", no_class, "SH specific commands.",
-                       &setshcmdlist, 0, &setlist);
-  add_show_prefix_cmd ("sh", no_class, "SH specific commands.",
-                      &showshcmdlist, 0, &showlist);
+  add_setshow_prefix_cmd ("sh", no_class,
+                         _("SH specific commands."),
+                         _("SH specific commands."),
+                         &setshcmdlist, &showshcmdlist,
+                         &setlist, &showlist);
   
   add_setshow_enum_cmd ("calling-convention", class_vars, sh_cc_enum,
                        &sh_active_calling_convention,
index 4587ecae7d197aec9689f26105e1bd4473cd9ed5..de1d68c0164783a7bd09bbf877b6abacc5239de2 100644 (file)
@@ -1962,14 +1962,12 @@ _initialize_target_descriptions ()
 
   tdesc_data = gdbarch_data_register_pre_init (tdesc_data_init);
 
-  add_basic_prefix_cmd ("tdesc", class_maintenance, _("\
-Set target description specific variables."),
-                       &tdesc_set_cmdlist,
-                       0 /* allow-unknown */, &setlist);
-  add_show_prefix_cmd ("tdesc", class_maintenance, _("\
-Show target description specific variables."),
-                      &tdesc_show_cmdlist,
-                      0 /* allow-unknown */, &showlist);
+  add_setshow_prefix_cmd ("tdesc", class_maintenance,
+                         _("Set target description specific variables."),
+                         _("Show target description specific variables."),
+                         &tdesc_set_cmdlist, &tdesc_show_cmdlist,
+                         &setlist, &showlist);
+
   add_basic_prefix_cmd ("tdesc", class_maintenance, _("\
 Unset target description specific variables."),
                        &tdesc_unset_cmdlist,
index a51e7b9f6da5ec9b2cd9f0d035e003e46855c4ee..8462d1eb1dae1ca43d712d6676d738b30e461f87 100644 (file)
@@ -987,12 +987,11 @@ _initialize_tui_win ()
 
   /* Define the classes of commands.
      They will appear in the help list in the reverse of this order.  */
-  add_basic_prefix_cmd ("tui", class_tui,
-                       _("TUI configuration variables."),
-                       &tui_setlist, 0 /* allow-unknown */, &setlist);
-  add_show_prefix_cmd ("tui", class_tui,
-                      _("TUI configuration variables."),
-                      &tui_showlist, 0 /* allow-unknown */, &showlist);
+  add_setshow_prefix_cmd ("tui", class_tui,
+                         _("TUI configuration variables."),
+                         _("TUI configuration variables."),
+                         &tui_setlist, &tui_showlist,
+                         &setlist, &showlist);
 
   add_com ("refresh", class_tui, tui_refresh_all_command,
           _("Refresh the terminal display."));
index 0d73baa882d30b7b4c44b8b33c6153041d557f17..8ca3d3efe2cbaed5e038fc6cbb1711f9331494ce 100644 (file)
@@ -851,12 +851,11 @@ Available FLAGS are:\n\
 Only one level of typedefs is unrolled.  See also \"ptype\"."));
   set_cmd_completer (c, expression_completer);
 
-  add_show_prefix_cmd ("type", no_class,
-                      _("Generic command for showing type-printing settings."),
-                      &showprinttypelist, 0, &showprintlist);
-  add_basic_prefix_cmd ("type", no_class,
-                       _("Generic command for setting how types print."),
-                       &setprinttypelist, 0, &setprintlist);
+  add_setshow_prefix_cmd ("type", no_class,
+                         _("Generic command for showing type-printing settings."),
+                         _("Generic command for setting how types print."),
+                         &setprinttypelist, &showprinttypelist,
+                         &setprintlist, &showprintlist);
 
   add_setshow_boolean_cmd ("methods", no_class, &print_methods,
                           _("\
index 5486c337a3c85b8b95e6f9ea0331bc27a71a1592..92a847aef4d6daa5a07c348cdcb87836a19c9481 100644 (file)
@@ -539,13 +539,9 @@ add_internal_problem_command (struct internal_problem *problem)
     = xstrprintf (_("Show what GDB does when %s is detected."),
                  problem->name);
 
-  add_basic_prefix_cmd (problem->name, class_maintenance, set_doc,
-                       set_cmd_list,
-                       0/*allow-unknown*/, &maintenance_set_cmdlist);
-
-  add_show_prefix_cmd (problem->name, class_maintenance, show_doc,
-                      show_cmd_list,
-                      0/*allow-unknown*/, &maintenance_show_cmdlist);
+  add_setshow_prefix_cmd (problem->name, class_maintenance,
+                         set_doc, show_doc, set_cmd_list, show_cmd_list,
+                         &maintenance_set_cmdlist, &maintenance_show_cmdlist);
 
   if (problem->user_settable_should_quit)
     {
index 6eb3db2ed44d0a724caada4a19cedbab2362e6b0..e5afb3d10a35e8dc4e2936ff8938509ad06dbd90 100644 (file)
@@ -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,