]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Avoid calling help_list in more places
authorTom Tromey <tom@tromey.com>
Sat, 11 Jan 2025 20:50:50 +0000 (13:50 -0700)
committerTom Tromey <tom@tromey.com>
Wed, 29 Jan 2025 17:21:49 +0000 (10:21 -0700)
I think there is no need to have a prefix command that simply calls
help_list.  Instead, add_basic_prefix_cmd can be used.  This patch
changes the relevant instances.  In one spot, add_setshow_prefix_cmd
is used instead.

gdb/printcmd.c
gdb/source.c
gdb/tui/tui-layout.c
gdb/tui/tui-win.c

index f1aaa644042e93a3435d7aaa4e8d26bfe9185f10..a9c4e935f3a6e088cc01af1d74097fa08afffbda 100644 (file)
@@ -2922,14 +2922,6 @@ show_memory_tagging_unsupported (void)
           " architecture."));
 }
 
-/* Implement the "memory-tag" prefix command.  */
-
-static void
-memory_tag_command (const char *arg, int from_tty)
-{
-  help_list (memory_tag_list, "memory-tag ", all_commands, gdb_stdout);
-}
-
 /* Helper for print-logical-tag and print-allocation-tag.  */
 
 static void
@@ -3386,7 +3378,7 @@ Convert the arguments to a string as \"printf\" would, but then\n\
 treat this string as a command line, and evaluate it."));
 
   /* Memory tagging commands.  */
-  add_prefix_cmd ("memory-tag", class_vars, memory_tag_command, _("\
+  add_basic_prefix_cmd ("memory-tag", class_vars, _("\
 Generic command for printing and manipulating memory tag properties."),
                  &memory_tag_list, 0, &cmdlist);
   add_cmd ("print-logical-tag", class_vars,
index a225280e794631908aeceab6110421bb7bd29089..0d6523cd305385b51af67bc6fa41d4c1e1075342 100644 (file)
@@ -1909,22 +1909,6 @@ source_lines_range::source_lines_range (int startline,
     }
 }
 
-/* Handle the "set source" base command.  */
-
-static void
-set_source (const char *arg, int from_tty)
-{
-  help_list (setsourcelist, "set source ", all_commands, gdb_stdout);
-}
-
-/* Handle the "show source" base command.  */
-
-static void
-show_source (const char *args, int from_tty)
-{
-  help_list (showsourcelist, "show source ", all_commands, gdb_stdout);
-}
-
 \f
 void _initialize_source ();
 void
@@ -2045,13 +2029,12 @@ By default, relative filenames are displayed."),
                        show_filename_display_string,
                        &setlist, &showlist);
 
-  add_prefix_cmd ("source", no_class, set_source,
-                 _("Generic command for setting how sources are handled."),
-                 &setsourcelist, 0, &setlist);
-
-  add_prefix_cmd ("source", no_class, show_source,
-                 _("Generic command for showing source settings."),
-                 &showsourcelist, 0, &showlist);
+  add_setshow_prefix_cmd
+    ("source", no_class,
+     _("Generic command for setting how sources are handled."),
+     _("Generic command for showing source settings."),
+     &setsourcelist, &showsourcelist,
+     &setlist, &showlist);
 
   add_setshow_boolean_cmd ("open", class_files, &source_open, _("\
 Set whether GDB should open source files."), _("\
index 2b6cb3194ae024479540d5a032e6dd97ff9e6081..79b7289c2a61fe93c5c1aa8cc375ff3bc9129fc1 100644 (file)
@@ -1120,14 +1120,6 @@ destroy_layout (struct cmd_list_element *self, void *context)
 
 static struct cmd_list_element *layout_list;
 
-/* Called to implement 'tui layout'.  */
-
-static void
-tui_layout_command (const char *args, int from_tty)
-{
-  help_list (layout_list, "tui layout ", all_commands, gdb_stdout);
-}
-
 /* Add a "layout" command with name NAME that switches to LAYOUT.  */
 
 static struct cmd_list_element *
@@ -1307,7 +1299,7 @@ void
 _initialize_tui_layout ()
 {
   struct cmd_list_element *layout_cmd
-    = add_prefix_cmd ("layout", class_tui, tui_layout_command, _("\
+    = add_basic_prefix_cmd ("layout", class_tui, _("\
 Change the layout of windows.\n\
 Usage: tui layout prev | next | LAYOUT-NAME"),
                      &layout_list, 0, tui_get_cmd_list ());
index 414d4699bea7e1cffd8a22439d739e4101abc40c..33b24d8946d9e770f2466648c05f4f89e8407ea9 100644 (file)
@@ -1082,14 +1082,6 @@ parse_scrolling_args (const char *arg,
 
 static cmd_list_element *tui_window_cmds = nullptr;
 
-/* Called to implement 'tui window'.  */
-
-static void
-tui_window_command (const char *args, int from_tty)
-{
-  help_list (tui_window_cmds, "tui window ", all_commands, gdb_stdout);
-}
-
 /* See tui-win.h.  */
 
 bool tui_left_margin_verbose = false;
@@ -1125,9 +1117,9 @@ Usage: tabset N"));
   deprecate_cmd (tabset_cmd, "set tui tab-width");
 
   /* Setup the 'tui window' list of command.  */
-  add_prefix_cmd ("window", class_tui, tui_window_command,
-                 _("Text User Interface window commands."),
-                 &tui_window_cmds, 1, tui_get_cmd_list ());
+  add_basic_prefix_cmd ("window", class_tui,
+                       _("Text User Interface window commands."),
+                       &tui_window_cmds, 1, tui_get_cmd_list ());
 
   cmd_list_element *winheight_cmd
     = add_cmd ("height", class_tui, tui_set_win_height_command, _("\