gdb: generate the prefix name for prefix commands on demand
authorMarco Barisione <mbarisione@undo.io>
Wed, 12 May 2021 10:19:22 +0000 (11:19 +0100)
committerMarco Barisione <mbarisione@undo.io>
Wed, 12 May 2021 10:19:22 +0000 (11:19 +0100)
Previously, the prefixname field of struct cmd_list_element was manually
set for prefix commands.  This seems verbose and error prone as it
required every single call to functions adding prefix commands to
specify the prefix name while the same information can be easily
generated.

Historically, this was not possible as the prefix field was null for
many commands, but this was fixed in commit
3f4d92ebdf7f848b5ccc9e8d8e8514c64fde1183 by Philippe Waroquiers, so
we can rely on the prefix field being set when generating the prefix
name.

This commit also fixes a use after free in this scenario:
* A command gets created via Python (using the gdb.Command class).
  The prefix name member is dynamically allocated.
* An alias to the new command is created. The alias's prefixname is set
  to point to the prefixname for the original command with a direct
  assignment.
* A new command with the same name as the Python command is created.
* The object for the original Python command gets freed and its
  prefixname gets freed as well.
* The alias is updated to point to the new command, but its prefixname
  is not updated so it keeps pointing to the freed one.

gdb/ChangeLog:

* command.h (add_prefix_cmd): Remove the prefixname argument as
it can now be generated automatically.  Update all callers.
(add_basic_prefix_cmd): Ditto.
(add_show_prefix_cmd): Ditto.
(add_prefix_cmd_suppress_notification): Ditto.
(add_abbrev_prefix_cmd): Ditto.
* cli/cli-decode.c (add_prefix_cmd): Ditto.
(add_basic_prefix_cmd): Ditto.
(add_show_prefix_cmd): Ditto.
(add_prefix_cmd_suppress_notification): Ditto.
(add_prefix_cmd_suppress_notification): Ditto.
(add_abbrev_prefix_cmd): Ditto.
* cli/cli-decode.h (struct cmd_list_element): Replace the
prefixname member variable with a method which generates the
prefix name at runtime.  Update all code reading the prefix
name to use the method, and remove all code setting it.
* python/py-cmd.c (cmdpy_destroyer): Remove code to free the
prefixname member as it's now a method.
(cmdpy_function): Determine if the command is a prefix by
looking at prefixlist, not prefixname.

69 files changed:
gdb/ada-lang.c
gdb/arc-tdep.c
gdb/arm-tdep.c
gdb/auto-load.c
gdb/breakpoint.c
gdb/bsd-kvm.c
gdb/btrace.c
gdb/cli/cli-cmds.c
gdb/cli/cli-decode.c
gdb/cli/cli-decode.h
gdb/cli/cli-dump.c
gdb/cli/cli-logging.c
gdb/cli/cli-script.c
gdb/cli/cli-setshow.c
gdb/cli/cli-style.c
gdb/cli/cli-style.h
gdb/command.h
gdb/compile/compile.c
gdb/cp-support.c
gdb/dcache.c
gdb/dwarf2/index-cache.c
gdb/dwarf2/read.c
gdb/f-lang.c
gdb/frame.c
gdb/gnu-nat.c
gdb/go32-nat.c
gdb/guile/guile.c
gdb/guile/scm-cmd.c
gdb/i386-tdep.c
gdb/infcmd.c
gdb/language.c
gdb/macrocmd.c
gdb/maint-test-options.c
gdb/maint-test-settings.c
gdb/maint.c
gdb/memattr.c
gdb/mips-tdep.c
gdb/printcmd.c
gdb/probe.c
gdb/python/py-cmd.c
gdb/python/python.c
gdb/ravenscar-thread.c
gdb/record-btrace.c
gdb/record-full.c
gdb/record.c
gdb/remote.c
gdb/riscv-tdep.c
gdb/rs6000-tdep.c
gdb/ser-tcp.c
gdb/serial.c
gdb/sh-tdep.c
gdb/skip.c
gdb/sparc64-tdep.c
gdb/stack.c
gdb/symfile.c
gdb/symtab.c
gdb/target-descriptions.c
gdb/target.c
gdb/thread.c
gdb/top.c
gdb/tracepoint.c
gdb/tui/tui-layout.c
gdb/tui/tui-win.c
gdb/typeprint.c
gdb/unittests/command-def-selftests.c
gdb/utils.c
gdb/valprint.c
gdb/value.c
gdb/windows-tdep.c

index 34b0e925685fc5cd529bf75cf2e4633e2acc498e..2a257c2fd6dbed74aeeb53b7220048851ef7be91 100644 (file)
@@ -13389,11 +13389,11 @@ _initialize_ada_language ()
 
   add_basic_prefix_cmd ("ada", no_class,
                        _("Prefix command for changing Ada-specific settings."),
-                       &set_ada_list, "set ada ", 0, &setlist);
+                       &set_ada_list, 0, &setlist);
 
   add_show_prefix_cmd ("ada", no_class,
                       _("Generic command for showing Ada-specific settings."),
-                      &show_ada_list, "show ada ", 0, &showlist);
+                      &show_ada_list, 0, &showlist);
 
   add_setshow_boolean_cmd ("trust-PAD-over-XVS", class_obscure,
                           &trust_pad_over_xvs, _("\
@@ -13472,12 +13472,12 @@ the regular expression are listed."));
 
   add_basic_prefix_cmd ("ada", class_maintenance,
                        _("Set Ada maintenance-related variables."),
-                       &maint_set_ada_cmdlist, "maintenance set ada ",
+                       &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, "maintenance show ada ",
+                      &maint_show_ada_cmdlist,
                       0/*allow-unknown*/, &maintenance_show_cmdlist);
 
   add_setshow_boolean_cmd
index 8a1da1a9868cc9a478263ade7b87e6bd5215aa7a..ece802545c040ef1b49dd7433695e2ddb56de097 100644 (file)
@@ -2495,7 +2495,7 @@ _initialize_arc_tdep ()
   add_show_prefix_cmd ("arc", class_maintenance,
                       _("ARC-specific maintenance commands for printing GDB "
                         "internal state."),
-                      &maintenance_print_arc_list, "maintenance print arc ",
+                      &maintenance_print_arc_list,
                       0, &maintenanceprintlist);
 
   add_cmd ("arc-instruction", class_maintenance,
index c473843f240ad511cc4508cd81ac1b17f846548a..7f56d00f55674a94392f8e17b52710a0a8b04208 100644 (file)
@@ -9563,11 +9563,11 @@ _initialize_arm_tdep ()
   /* Add root prefix command for all "set arm"/"show arm" commands.  */
   add_basic_prefix_cmd ("arm", no_class,
                        _("Various ARM-specific commands."),
-                       &setarmcmdlist, "set arm ", 0, &setlist);
+                       &setarmcmdlist, 0, &setlist);
 
   add_show_prefix_cmd ("arm", no_class,
                       _("Various ARM-specific commands."),
-                      &showarmcmdlist, "show arm ", 0, &showlist);
+                      &showarmcmdlist, 0, &showlist);
 
 
   arm_disassembler_options = xstrdup ("reg-names-std");
index d1ae6deacee715fc1c1b0731d659783ecbdac546..b9478c45c53492904c3bd603c84fe245d4b799c6 100644 (file)
@@ -1427,8 +1427,7 @@ auto_load_set_cmdlist_get (void)
 Auto-loading specific settings.\n\
 Configure various auto-load-specific variables such as\n\
 automatic loading of Python scripts."),
-                   &retval, "set auto-load ",
-                   1/*allow-unknown*/, &setlist);
+                   &retval, 1/*allow-unknown*/, &setlist);
 
   return &retval;
 }
@@ -1445,8 +1444,7 @@ auto_load_show_cmdlist_get (void)
 Show auto-loading specific settings.\n\
 Show configuration of various auto-load-specific variables such as\n\
 automatic loading of Python scripts."),
-                        &retval, "show auto-load ",
-                        0/*allow-unknown*/, &showlist);
+                        &retval, 0/*allow-unknown*/, &showlist);
 
   return &retval;
 }
@@ -1488,8 +1486,7 @@ auto_load_info_cmdlist_get (void)
 Print current status of auto-loaded files.\n\
 Print whether various files like Python scripts or .gdbinit files have been\n\
 found and/or loaded."),
-                   &retval, "info auto-load ",
-                   0/*allow-unknown*/, &infolist);
+                   &retval, 0/*allow-unknown*/, &infolist);
 
   return &retval;
 }
index 38406b45856cef058854729e1aad884ffc337667..d479f0089489ef23a70de9b5dced85ed90b8a600 100644 (file)
@@ -15731,7 +15731,7 @@ Give breakpoint numbers (separated by spaces) as arguments.\n\
 With no subcommand, breakpoints are enabled until you command otherwise.\n\
 This is used to cancel the effect of the \"disable\" command.\n\
 With a subcommand you can enable temporarily."),
-                 &enablelist, "enable ", 1, &cmdlist);
+                 &enablelist, 1, &cmdlist);
 
   add_com_alias ("en", "enable", class_breakpoint, 1);
 
@@ -15741,7 +15741,7 @@ Usage: enable breakpoints [BREAKPOINTNUM]...\n\
 Give breakpoint numbers (separated by spaces) as arguments.\n\
 This is used to cancel the effect of the \"disable\" command.\n\
 May be abbreviated to simply \"enable\"."),
-                  &enablebreaklist, "enable breakpoints ", 1, &enablelist);
+                  &enablebreaklist, 1, &enablelist);
 
   add_cmd ("once", no_class, enable_once_command, _("\
 Enable some breakpoints for one hit.\n\
@@ -15787,7 +15787,7 @@ Usage: disable [BREAKPOINTNUM]...\n\
 Arguments are breakpoint numbers with spaces in between.\n\
 To disable all breakpoints, give no argument.\n\
 A disabled breakpoint is not forgotten, but has no effect until re-enabled."),
-                 &disablelist, "disable ", 1, &cmdlist);
+                 &disablelist, 1, &cmdlist);
   add_com_alias ("dis", "disable", class_breakpoint, 1);
   add_com_alias ("disa", "disable", class_breakpoint, 1);
 
@@ -15807,7 +15807,7 @@ Arguments are breakpoint numbers with spaces in between.\n\
 To delete all breakpoints, give no argument.\n\
 \n\
 Also a prefix command for deletion of other GDB objects."),
-                 &deletelist, "delete ", 1, &cmdlist);
+                 &deletelist, 1, &cmdlist);
   add_com_alias ("d", "delete", class_breakpoint, 1);
   add_com_alias ("del", "delete", class_breakpoint, 1);
 
@@ -15843,7 +15843,7 @@ BREAK_ARGS_HELP ("break")));
     {
       add_abbrev_prefix_cmd ("stop", class_breakpoint, stop_command, _("\
 Break in function/address or break at a line in the current file."),
-                            &stoplist, "stop ", 1, &cmdlist);
+                            &stoplist, 1, &cmdlist);
       add_cmd ("in", class_breakpoint, stopin_command,
               _("Break in function or address."), &stoplist);
       add_cmd ("at", class_breakpoint, stopat_command,
@@ -15906,12 +15906,12 @@ breakpoint set."),
 
   add_basic_prefix_cmd ("catch", class_breakpoint, _("\
 Set catchpoints to catch events."),
-                       &catch_cmdlist, "catch ",
+                       &catch_cmdlist,
                        0/*allow-unknown*/, &cmdlist);
 
   add_basic_prefix_cmd ("tcatch", class_breakpoint, _("\
 Set temporary catchpoints to catch events."),
-                       &tcatch_cmdlist, "tcatch ",
+                       &tcatch_cmdlist,
                        0/*allow-unknown*/, &cmdlist);
 
   add_catch_command ("fork", _("Catch calls to fork."),
@@ -16083,7 +16083,7 @@ if TPNUM is omitted, passcount refers to the last tracepoint defined."));
 
   add_basic_prefix_cmd ("save", class_breakpoint,
                        _("Save breakpoint definitions as a script."),
-                       &save_cmdlist, "save ",
+                       &save_cmdlist,
                        0/*allow-unknown*/, &cmdlist);
 
   c = add_cmd ("breakpoints", class_breakpoint, save_breakpoints_command, _("\
@@ -16107,13 +16107,13 @@ Use the 'source' command in another debug session to restore them."),
 Breakpoint specific settings.\n\
 Configure various breakpoint-specific variables such as\n\
 pending breakpoint behavior."),
-                       &breakpoint_set_cmdlist, "set breakpoint ",
+                       &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, "show breakpoint ",
+                      &breakpoint_show_cmdlist,
                       0/*allow-unknown*/, &showlist);
 
   add_setshow_auto_boolean_cmd ("pending", no_class,
index 89da40afcb78f213a1a9ab62d9bb9ef99ec6d73f..d058aac39ec656e95d8398410049584e816305ad 100644 (file)
@@ -388,7 +388,7 @@ bsd_kvm_add_target (int (*supply_pcb)(struct regcache *, struct pcb *))
   
   add_prefix_cmd ("kvm", class_obscure, bsd_kvm_cmd, _("\
 Generic command for manipulating the kernel memory interface."),
-                 &bsd_kvm_cmdlist, "kvm ", 0, &cmdlist);
+                 &bsd_kvm_cmdlist, 0, &cmdlist);
 
 #ifndef HAVE_STRUCT_THREAD_TD_PCB
   add_cmd ("proc", class_obscure, bsd_kvm_proc_cmd,
index 17eb56c6d0597d1a018b72743fac0baa24af0a1d..5e689c11d4bdd929a5581a42d9e7f1d482acf05a 100644 (file)
@@ -3441,29 +3441,26 @@ _initialize_btrace ()
 
   add_basic_prefix_cmd ("btrace", class_maintenance,
                        _("Branch tracing maintenance commands."),
-                       &maint_btrace_cmdlist, "maintenance btrace ",
-                       0, &maintenancelist);
+                       &maint_btrace_cmdlist, 0, &maintenancelist);
 
   add_basic_prefix_cmd ("btrace", class_maintenance, _("\
 Set branch tracing specific variables."),
-                       &maint_btrace_set_cmdlist, "maintenance set btrace ",
+                       &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,
-                       "maintenance set btrace pt ",
                        0, &maint_btrace_set_cmdlist);
 
   add_show_prefix_cmd ("btrace", class_maintenance, _("\
 Show branch tracing specific variables."),
-                      &maint_btrace_show_cmdlist, "maintenance show btrace ",
+                      &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,
-                      "maintenance show btrace pt ",
                       0, &maint_btrace_show_cmdlist);
 
   add_setshow_boolean_cmd ("skip-pad", class_maintenance,
index 62948f5fc7bef7cb131c456806d00d2970c94539..284b75192581e64a393725b88a4c272cd016c28c 100644 (file)
@@ -2352,10 +2352,10 @@ Show verbosity."), NULL,
 
   add_basic_prefix_cmd ("history", class_support, _("\
 Generic command for setting command history parameters."),
-                       &sethistlist, "set history ", 0, &setlist);
+                       &sethistlist, 0, &setlist);
   add_show_prefix_cmd ("history", class_support, _("\
 Generic command for showing command history parameters."),
-                      &showhistlist, "show history ", 0, &showlist);
+                      &showhistlist, 0, &showlist);
 
   add_setshow_boolean_cmd ("expansion", no_class, &history_expansion_p, _("\
 Set history expansion on command input."), _("\
@@ -2367,7 +2367,7 @@ Without an argument, history expansion is enabled."),
 
   add_prefix_cmd ("info", class_info, info_command, _("\
 Generic command for showing things about the program being debugged."),
-                 &infolist, "info ", 0, &cmdlist);
+                 &infolist, 0, &cmdlist);
   add_com_alias ("i", "info", class_info, 1);
   add_com_alias ("inf", "info", class_info, 1);
 
@@ -2376,7 +2376,7 @@ Generic command for showing things about the program being debugged."),
 
   c = add_show_prefix_cmd ("show", class_info, _("\
 Generic command for showing things about the debugger."),
-                          &showlist, "show ", 0, &cmdlist);
+                          &showlist, 0, &cmdlist);
   /* Another way to get at the same thing.  */
   add_alias_cmd ("set", c, class_info, 0, &infolist);
 
@@ -2449,11 +2449,11 @@ the previous command number shown."),
 
   add_basic_prefix_cmd ("debug", no_class,
                        _("Generic command for setting gdb debugging flags."),
-                       &setdebuglist, "set debug ", 0, &setlist);
+                       &setdebuglist, 0, &setlist);
 
   add_show_prefix_cmd ("debug", no_class,
                       _("Generic command for showing gdb debugging flags."),
-                      &showdebuglist, "show debug ", 0, &showlist);
+                      &showdebuglist, 0, &showlist);
 
   c = add_com ("shell", class_support, shell_command, _("\
 Execute the rest of the line as a shell command.\n\
index f48a9add4d4ea2a663bd1645c501f357d4fe1f91..32edb526c8755fd7de7e7561338af27457262f6e 100644 (file)
@@ -318,7 +318,6 @@ add_alias_cmd (const char *name, cmd_list_element *old,
   c->func = old->func;
   c->function = old->function;
   c->prefixlist = old->prefixlist;
-  c->prefixname = old->prefixname;
   c->allow_unknown = old->allow_unknown;
   c->abbrev_flag = abbrev_flag;
   c->cmd_pointer = old;
@@ -383,13 +382,11 @@ struct cmd_list_element *
 add_prefix_cmd (const char *name, enum command_class theclass,
                cmd_const_cfunc_ftype *fun,
                const char *doc, struct cmd_list_element **prefixlist,
-               const char *prefixname, int allow_unknown,
-               struct cmd_list_element **list)
+               int allow_unknown, struct cmd_list_element **list)
 {
   struct cmd_list_element *c = add_cmd (name, theclass, fun, doc, list);
 
   c->prefixlist = prefixlist;
-  c->prefixname = prefixname;
   c->allow_unknown = allow_unknown;
 
   /* Now that prefix command C is defined, we need to set the prefix field
@@ -409,7 +406,8 @@ do_prefix_cmd (const char *args, int from_tty, struct cmd_list_element *c)
   while (c->cmd_pointer != nullptr)
     c = c->cmd_pointer;
 
-  help_list (*c->prefixlist, c->prefixname, all_commands, gdb_stdout);
+  help_list (*c->prefixlist, c->prefixname ().c_str (),
+            all_commands, gdb_stdout);
 }
 
 /* See command.h.  */
@@ -417,11 +415,10 @@ do_prefix_cmd (const char *args, int from_tty, struct cmd_list_element *c)
 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)
+                     int allow_unknown, struct cmd_list_element **list)
 {
   struct cmd_list_element *cmd = add_prefix_cmd (name, theclass, nullptr,
-                                                doc, prefixlist, prefixname,
+                                                doc, prefixlist,
                                                 allow_unknown, list);
   set_cmd_sfunc (cmd, do_prefix_cmd);
   return cmd;
@@ -441,11 +438,10 @@ do_show_prefix_cmd (const char *args, int from_tty, struct cmd_list_element *c)
 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)
+                    int allow_unknown, struct cmd_list_element **list)
 {
   struct cmd_list_element *cmd = add_prefix_cmd (name, theclass, nullptr,
-                                                doc, prefixlist, prefixname,
+                                                doc, prefixlist,
                                                 allow_unknown, list);
   set_cmd_sfunc (cmd, do_show_prefix_cmd);
   return cmd;
@@ -459,13 +455,12 @@ add_prefix_cmd_suppress_notification
               (const char *name, enum command_class theclass,
                cmd_const_cfunc_ftype *fun,
                const char *doc, struct cmd_list_element **prefixlist,
-               const char *prefixname, int allow_unknown,
-               struct cmd_list_element **list,
+               int allow_unknown, struct cmd_list_element **list,
                int *suppress_notification)
 {
   struct cmd_list_element *element
     = add_prefix_cmd (name, theclass, fun, doc, prefixlist,
-                     prefixname, allow_unknown, list);
+                     allow_unknown, list);
   element->suppress_notification = suppress_notification;
   return element;
 }
@@ -476,13 +471,11 @@ struct cmd_list_element *
 add_abbrev_prefix_cmd (const char *name, enum command_class theclass,
                       cmd_const_cfunc_ftype *fun, const char *doc,
                       struct cmd_list_element **prefixlist,
-                      const char *prefixname,
                       int allow_unknown, struct cmd_list_element **list)
 {
   struct cmd_list_element *c = add_cmd (name, theclass, fun, doc, list);
 
   c->prefixlist = prefixlist;
-  c->prefixname = prefixname;
   c->allow_unknown = allow_unknown;
   c->abbrev_flag = 1;
   return c;
@@ -1034,10 +1027,11 @@ add_com_suppress_notification (const char *name, enum command_class theclass,
 static void
 fput_command_name_styled (struct cmd_list_element *c, struct ui_file *stream)
 {
-  const char *prefixname
-    = c->prefix == nullptr ? "" : c->prefix->prefixname;
+  std::string prefixname
+    = c->prefix == nullptr ? "" : c->prefix->prefixname ();
 
-  fprintf_styled (stream, title_style.style (), "%s%s", prefixname, c->name);
+  fprintf_styled (stream, title_style.style (), "%s%s",
+                 prefixname.c_str (), c->name);
 }
 
 /* Print the definition of alias C using title style for alias
@@ -1192,7 +1186,8 @@ apropos_cmd (struct ui_file *stream,
        {
          /* Recursively call ourselves on the subcommand list,
             passing the right prefix in.  */
-         apropos_cmd (stream, *c->prefixlist, verbose, regex, c->prefixname);
+         apropos_cmd (stream, *c->prefixlist, verbose, regex,
+                      c->prefixname ().c_str ());
        }
     }
 }
@@ -1258,7 +1253,8 @@ help_cmd (const char *command, struct ui_file *stream)
 
   /* If this is a prefix command, print it's subcommands.  */
   if (c->prefixlist)
-    help_list (*c->prefixlist, c->prefixname, all_commands, stream);
+    help_list (*c->prefixlist, c->prefixname ().c_str (),
+              all_commands, stream);
 
   /* If this is a class name, print all of the commands in the class.  */
   if (c->func == NULL)
@@ -1812,7 +1808,8 @@ lookup_cmd (const char **line, struct cmd_list_element *list,
         values.  */
       int local_allow_unknown = (last_list ? last_list->allow_unknown :
                                 allow_unknown);
-      const char *local_cmdtype = last_list ? last_list->prefixname : cmdtype;
+      std::string local_cmdtype
+       = last_list ? last_list->prefixname () : cmdtype;
       struct cmd_list_element *local_list =
        (last_list ? *(last_list->prefixlist) : list);
 
@@ -1852,8 +1849,8 @@ lookup_cmd (const char **line, struct cmd_list_element *list,
                    break;
                  }
              }
-         error (_("Ambiguous %scommand \"%s\": %s."), local_cmdtype,
-                *line, ambbuf);
+         error (_("Ambiguous %scommand \"%s\": %s."),
+                local_cmdtype.c_str (), *line, ambbuf);
        }
     }
   else
@@ -1867,7 +1864,7 @@ lookup_cmd (const char **line, struct cmd_list_element *list,
        (*line)++;
 
       if (c->prefixlist && **line && !c->allow_unknown)
-       undef_cmd_error (c->prefixname, *line);
+       undef_cmd_error (c->prefixname ().c_str (), *line);
 
       /* Seems to be what he wants.  Return it.  */
       return c;
@@ -1940,7 +1937,7 @@ deprecated_cmd_warning (const char *text, struct cmd_list_element *list)
   /* Join command prefix (if any) and the command name.  */
   std::string tmp_cmd_str;
   if (cmd->prefix != nullptr)
-    tmp_cmd_str += std::string (cmd->prefix->prefixname);
+    tmp_cmd_str += cmd->prefix->prefixname ();
   tmp_cmd_str += std::string (cmd->name);
 
   /* Display the appropriate first line, this warns that the thing the user
@@ -1950,7 +1947,7 @@ deprecated_cmd_warning (const char *text, struct cmd_list_element *list)
       /* Join the alias prefix (if any) and the alias name.  */
       std::string tmp_alias_str;
       if (alias->prefix != nullptr)
-       tmp_alias_str += std::string (alias->prefix->prefixname);
+       tmp_alias_str += alias->prefix->prefixname ();
       tmp_alias_str += std::string (alias->name);
 
       if (cmd->cmd_deprecated)
index d6f52a21da78847062544ab351edd7dae87df197..214428eab0482c9fcc9eac537bb8ca2ea01900ea 100644 (file)
@@ -71,6 +71,25 @@ struct cmd_list_element
 
   DISABLE_COPY_AND_ASSIGN (cmd_list_element);
 
+  /* For prefix commands, return a string containing prefix commands to
+     get here: this one plus any others needed to get to it.  Ends in a
+     space.  It is used before the word "command" in describing the
+     commands reached through this prefix.
+
+     For non-prefix commands, an empty string is returned.  */
+  std::string prefixname ()
+  {
+    if (prefixlist == nullptr)
+      /* Not a prefix command.  */
+      return "";
+
+    std::string prefixname;
+    if (prefix != nullptr)
+      prefixname = prefix->prefixname ();
+    prefixname += name;
+    prefixname += " ";
+    return prefixname;
+  }
 
   /* Points to next command in this list.  */
   struct cmd_list_element *next = nullptr;
@@ -186,13 +205,6 @@ struct cmd_list_element
      of the variable containing the list of subcommands.  */
   struct cmd_list_element **prefixlist = nullptr;
 
-  /* For prefix commands only:
-     String containing prefix commands to get here: this one
-     plus any others needed to get to it.  Should end in a space.
-     It is used before the word "command" in describing the
-     commands reached through this prefix.  */
-  const char *prefixname = nullptr;
-
   /* The prefix command of this command.  */
   struct cmd_list_element *prefix = nullptr;
 
index 1df26626f9d2b1e52af8e7fa72232d5fbce8dd4b..95ce85e1c44995b7629e374f2e6cc0a9f163b399 100644 (file)
@@ -572,12 +572,12 @@ _initialize_cli_dump ()
 
   add_basic_prefix_cmd ("dump", class_vars,
                        _("Dump target code/data to a local file."),
-                       &dump_cmdlist, "dump ",
+                       &dump_cmdlist,
                        0/*allow-unknown*/,
                        &cmdlist);
   add_basic_prefix_cmd ("append", class_vars,
                        _("Append target code/data to a local file."),
-                       &append_cmdlist, "append ",
+                       &append_cmdlist,
                        0/*allow-unknown*/,
                        &cmdlist);
 
@@ -593,37 +593,37 @@ the specified FILE in raw target ordered bytes.");
 
   add_basic_prefix_cmd ("srec", all_commands,
                        _("Write target code/data to an srec file."),
-                       &srec_cmdlist, "dump srec ", 
+                       &srec_cmdlist,
                        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 ", 
+                       &ihex_cmdlist,
                        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 ",
+                       &verilog_cmdlist,
                        0 /*allow-unknown*/,
                        &dump_cmdlist);
 
   add_basic_prefix_cmd ("tekhex", all_commands,
                        _("Write target code/data to a tekhex file."),
-                       &tekhex_cmdlist, "dump tekhex ", 
+                       &tekhex_cmdlist,
                        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 ", 
+                       &binary_dump_cmdlist,
                        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 ", 
+                       &binary_append_cmdlist,
                        0 /*allow-unknown*/, 
                        &append_cmdlist);
 
index 9cde7b9e9035eb5f7879fed99edcaf718bc71bc6..dfedd7599a2fd0b22124ea94ddf30a6091eb0025 100644 (file)
@@ -173,10 +173,10 @@ _initialize_cli_logging ()
 
   add_basic_prefix_cmd ("logging", class_support,
                        _("Set logging options."), &set_logging_cmdlist,
-                       "set logging ", 0, &setlist);
+                       0, &setlist);
   add_show_prefix_cmd ("logging", class_support,
                       _("Show logging options."), &show_logging_cmdlist,
-                      "show logging ", 0, &showlist);
+                      0, &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 0544f3efb1badf64312609ac16d2816c8d0e2a50..eb8853a5e649a7afc6ea601cf529be57bc21a971 100644 (file)
@@ -1472,7 +1472,6 @@ do_define_command (const char *comname, int from_tty,
   {
     struct cmd_list_element **c_prefixlist
       = c == nullptr ? nullptr : c->prefixlist;
-    const char *c_prefixname = c == nullptr ? nullptr : c->prefixname;
 
     newc = add_cmd (comname, class_user, user_defined_command,
                    (c != nullptr && c->theclass == class_user)
@@ -1484,7 +1483,6 @@ do_define_command (const char *comname, int from_tty,
     if (c_prefixlist != nullptr)
       {
        newc->prefixlist = c_prefixlist;
-       newc->prefixname = c_prefixname;
        /* allow_unknown: see explanation in equivalent logic in
           define_prefix_command ().  */
        newc->allow_unknown = newc->user_commands.get () != nullptr;
@@ -1615,7 +1613,6 @@ define_prefix_command (const char *comname, int from_tty)
      command.  */
   c->prefixlist = new struct cmd_list_element*;
   *(c->prefixlist) = nullptr;
-  c->prefixname = xstrprintf ("%s ", comfull);
   /* If the prefix command C is not a command, then it must be followed
      by known subcommands.  Otherwise, if C is also a normal command,
      it can be followed by C args that must not cause a 'subcommand'
@@ -1681,11 +1678,11 @@ show_user_1 (struct cmd_list_element *c, const char *prefix, const char *name,
 
   if (c->prefixlist != NULL)
     {
-      const char *prefixname = c->prefixname;
+      const std::string prefixname = c->prefixname ();
 
       for (c = *c->prefixlist; c != NULL; c = c->next)
        if (c->theclass == class_user || c->prefixlist != NULL)
-         show_user_1 (c, prefixname, c->name, gdb_stdout);
+         show_user_1 (c, prefixname.c_str (), c->name, gdb_stdout);
     }
 
 }
index 1a8c6e2f62aaf0d98bcd8fa4437e021e1083cf93..1b14df70711b2ef0534ced8efe1e0649f8569008 100644 (file)
@@ -747,7 +747,8 @@ cmd_show_list (struct cmd_list_element *list, int from_tty)
       if (list->prefixlist && list->cmd_pointer == nullptr)
        {
          ui_out_emit_tuple optionlist_emitter (uiout, "optionlist");
-         const char *new_prefix = strstr (list->prefixname, "show ") + 5;
+         std::string prefixname = list->prefixname ();
+         const char *new_prefix = strstr (prefixname.c_str (), "show ") + 5;
 
          if (uiout->is_mi_like_p ())
            uiout->field_string ("prefix", new_prefix);
@@ -757,13 +758,14 @@ cmd_show_list (struct cmd_list_element *list, int from_tty)
        {
          ui_out_emit_tuple option_emitter (uiout, "option");
 
-         {
-           /* If we find a prefix, output it (with "show " skipped).  */
-           const char *prefixname
-             = (list->prefix == nullptr ? ""
-                : strstr (list->prefix->prefixname, "show ") + 5);
-           uiout->text (prefixname);
-         }
+         if (list->prefix != nullptr)
+           {
+             /* If we find a prefix, output it (with "show " skipped).  */
+             std::string prefixname = list->prefix->prefixname ();
+             prefixname = (list->prefix->prefixlist == nullptr ? ""
+                           : strstr (prefixname.c_str (), "show ") + 5);
+             uiout->text (prefixname.c_str ());
+           }
          uiout->field_string ("name", list->name);
          uiout->text (":  ");
          if (list->type == show_cmd)
index 8b4b6b24cda4396fdef7aaa66f82403a437b10c4..25a1d888f860508be901fe2bc854c4c8e258c1d4 100644 (file)
@@ -225,13 +225,10 @@ cli_style_option::add_setshow_commands (enum command_class theclass,
                                        struct cmd_list_element **show_list,
                                        bool skip_intensity)
 {
-  m_set_prefix = std::string ("set style ") + m_name + " ";
-  m_show_prefix = std::string ("show style ") + m_name + " ";
-
   add_basic_prefix_cmd (m_name, no_class, prefix_doc, &m_set_list,
-                       m_set_prefix.c_str (), 0, set_list);
+                       0, set_list);
   add_show_prefix_cmd (m_name, no_class, prefix_doc, &m_show_list,
-                      m_show_prefix.c_str (), 0, show_list);
+                      0, show_list);
 
   add_setshow_enum_cmd ("foreground", theclass, cli_colors,
                        &m_foreground,
@@ -297,11 +294,11 @@ _initialize_cli_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);
+                 &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, "show style ", 0, &showlist);
+                 &style_show_list, 0, &showlist);
 
   add_setshow_boolean_cmd ("enabled", no_class, &cli_styling, _("\
 Set whether CLI styling is enabled."), _("\
index 187e1d07ce7dbc12d8dd8c6a6bee626af2c9a773..78bc2cd6f1ed1d057ff68cd20b4b7379de5d062c 100644 (file)
@@ -72,9 +72,6 @@ private:
   /* The intensity.  */
   const char *m_intensity;
 
-  /* Storage for prefixes needed when registering the commands.  */
-  std::string m_show_prefix;
-  std::string m_set_prefix;
   /* Storage for command lists needed when registering
      subcommands.  */
   struct cmd_list_element *m_set_list = nullptr;
index 827a19637a2d14921772846d6f0468d4fc5a9a48..33feb19166c690e2ea23f888940e3b3781e9445c 100644 (file)
@@ -188,7 +188,7 @@ extern struct cmd_list_element *add_prefix_cmd (const char *, enum command_class
                                                cmd_const_cfunc_ftype *fun,
                                                const char *,
                                                struct cmd_list_element **,
-                                               const char *, int,
+                                               int,
                                                struct cmd_list_element **);
 
 /* Like add_prefix_cmd, but sets the callback to a function that
@@ -196,20 +196,20 @@ extern struct cmd_list_element *add_prefix_cmd (const char *, enum command_class
 
 extern struct cmd_list_element *add_basic_prefix_cmd
   (const char *, enum command_class, const char *, struct cmd_list_element **,
-   const char *, int, struct cmd_list_element **);
+   int, struct cmd_list_element **);
 
 /* Like add_prefix_cmd, but useful for "show" prefixes.  This sets the
    callback to a function that simply calls cmd_show_list.  */
 
 extern struct cmd_list_element *add_show_prefix_cmd
   (const char *, enum command_class, const char *, struct cmd_list_element **,
-   const char *, int, struct cmd_list_element **);
+   int, struct cmd_list_element **);
 
 extern struct cmd_list_element *add_prefix_cmd_suppress_notification
                        (const char *name, enum command_class theclass,
                         cmd_const_cfunc_ftype *fun,
                         const char *doc, struct cmd_list_element **prefixlist,
-                        const char *prefixname, int allow_unknown,
+                        int allow_unknown,
                         struct cmd_list_element **list,
                         int *suppress_notification);
 
@@ -218,7 +218,7 @@ extern struct cmd_list_element *add_abbrev_prefix_cmd (const char *,
                                                       cmd_const_cfunc_ftype *fun,
                                                       const char *,
                                                       struct cmd_list_element
-                                                      **, const char *, int,
+                                                      **, int,
                                                       struct cmd_list_element
                                                       **);
 
index 5c5d51782c902e05a0bd33412089bfa7b290f9c2..c7f7d384752bddd71772b904be66ca9e796ca902 100644 (file)
@@ -930,7 +930,7 @@ _initialize_compile ()
   compile_cmd_element = add_prefix_cmd ("compile", class_obscure,
                                        compile_command, _("\
 Command to compile source code and inject it into the inferior."),
-                 &compile_command_list, "compile ", 1, &cmdlist);
+                 &compile_command_list, 1, &cmdlist);
   add_com_alias ("expression", "compile", class_obscure, 0);
 
   const auto compile_opts = make_compile_options_def_group (nullptr);
index eba477d549d1c124338fb2d67551c79322388d91..e87c9d420e40dfd627931ab28fbcb07c544f9a23 100644 (file)
@@ -2212,7 +2212,6 @@ _initialize_cp_support ()
   add_basic_prefix_cmd ("cplus", class_maintenance,
                        _("C++ maintenance commands."),
                        &maint_cplus_cmd_list,
-                       "maintenance cplus ",
                        0, &maintenancelist);
   add_alias_cmd ("cp", "cplus",
                 class_maintenance, 1,
index 201505bf9e9ea53ef75e758cde303c75f4430e7a..50b3854fe69e6bc8aee952c71ad88b63f0b9b495 100644 (file)
@@ -696,11 +696,10 @@ the contents of the given line."));
 
   add_basic_prefix_cmd ("dcache", class_obscure, _("\
 Use this command to set number of lines in dcache and line-size."),
-                       &dcache_set_list, "set dcache ", /*allow_unknown*/0,
-                       &setlist);
+                       &dcache_set_list, /*allow_unknown*/0, &setlist);
   add_show_prefix_cmd ("dcache", class_obscure, _("\
 Show dcachesettings."),
-                      &dcache_show_list, "show dcache ", /*allow_unknown*/0,
+                      &dcache_show_list, /*allow_unknown*/0,
                       &showlist);
 
   add_setshow_zuinteger_cmd ("line-size", class_obscure,
index ed8fd8e64e66a097e149f0505de64d0fa112a6ac..c3decf16ead6f455351dcffb0104c863a6fb4cad 100644 (file)
@@ -335,12 +335,12 @@ _initialize_index_cache ()
   add_basic_prefix_cmd ("index-cache", class_files,
                        _("Set index-cache options."),
                        &set_index_cache_prefix_list,
-                       "set index-cache ", false, &setlist);
+                       false, &setlist);
 
   /* show index-cache */
   add_prefix_cmd ("index-cache", class_files, show_index_cache_command,
                  _("Show index-cache options."), &show_index_cache_prefix_list,
-                 "show index-cache ", false, &showlist);
+                 false, &showlist);
 
   /* set index-cache on */
   add_cmd ("on", class_files, set_index_cache_on_command,
index b2f48f1f395608d13b859ad76c92e736221e248a..280f56c31e0db860802804cff054623152e9390a 100644 (file)
@@ -25079,13 +25079,13 @@ _initialize_dwarf2_read ()
   add_basic_prefix_cmd ("dwarf", class_maintenance, _("\
 Set DWARF specific variables.\n\
 Configure DWARF variables such as the cache size."),
-                       &set_dwarf_cmdlist, "maintenance set dwarf ",
+                       &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, "maintenance show dwarf ",
+                      &show_dwarf_cmdlist,
                       0/*allow-unknown*/, &maintenance_show_cmdlist);
 
   add_setshow_zinteger_cmd ("max-cache-age", class_obscure,
index 7e921b99517c42c707fc9738a7426082bdbfebfa..5731c40030545e176e88bf152e29d7bca900b0eb 100644 (file)
@@ -1685,11 +1685,11 @@ _initialize_f_language ()
 
   add_basic_prefix_cmd ("fortran", no_class,
                        _("Prefix command for changing Fortran-specific settings."),
-                       &set_fortran_list, "set fortran ", 0, &setlist);
+                       &set_fortran_list, 0, &setlist);
 
   add_show_prefix_cmd ("fortran", no_class,
                       _("Generic command for showing Fortran-specific settings."),
-                      &show_fortran_list, "show fortran ", 0, &showlist);
+                      &show_fortran_list, 0, &showlist);
 
   add_setshow_boolean_cmd ("repack-array-slices", class_vars,
                           &repack_array_slices, _("\
index cd10f3f0770b593e1b7ba8e0f4a8a08e7f705c07..d2e14c831a09a3e03333ed7b75ad8bdcc3f4cd2f 100644 (file)
@@ -3171,12 +3171,12 @@ _initialize_frame ()
   add_basic_prefix_cmd ("backtrace", class_maintenance, _("\
 Set backtrace specific variables.\n\
 Configure backtrace variables such as the backtrace limit"),
-                       &set_backtrace_cmdlist, "set backtrace ",
+                       &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, "show backtrace ",
+                      &show_backtrace_cmdlist,
                       0/*allow-unknown*/, &showlist);
 
   add_setshow_uinteger_cmd ("limit", class_obscure,
index 816f901ce23e2292461c494a51ada51013869c43..aadd3e894ce1244e379ad57808cda45c9e0e8d99 100644 (file)
@@ -3238,10 +3238,10 @@ Show whether exceptions in the inferior process will be trapped."),
 
   add_prefix_cmd ("task", no_class, set_task_cmd,
                  _("Command prefix for setting task attributes."),
-                 &set_task_cmd_list, "set task ", 0, &setlist);
+                 &set_task_cmd_list, 0, &setlist);
   add_prefix_cmd ("task", no_class, show_task_cmd,
                  _("Command prefix for showing task attributes."),
-                 &show_task_cmd_list, "show task ", 0, &showlist);
+                 &show_task_cmd_list, 0, &showlist);
 
   add_cmd ("pause", class_run, set_task_pause_cmd, _("\
 Set whether the task is suspended while gdb has control.\n\
@@ -3410,17 +3410,17 @@ add_thread_commands (void)
 {
   add_prefix_cmd ("thread", no_class, set_thread_cmd,
                  _("Command prefix for setting thread properties."),
-                 &set_thread_cmd_list, "set thread ", 0, &setlist);
+                 &set_thread_cmd_list, 0, &setlist);
   add_prefix_cmd ("default", no_class, show_thread_cmd,
                  _("Command prefix for setting default thread properties."),
-                 &set_thread_default_cmd_list, "set thread default ", 0,
+                 &set_thread_default_cmd_list, 0,
                  &set_thread_cmd_list);
   add_prefix_cmd ("thread", no_class, set_thread_default_cmd,
                  _("Command prefix for showing thread properties."),
-                 &show_thread_cmd_list, "show thread ", 0, &showlist);
+                 &show_thread_cmd_list, 0, &showlist);
   add_prefix_cmd ("default", no_class, show_thread_default_cmd,
                  _("Command prefix for showing default thread properties."),
-                 &show_thread_default_cmd_list, "show thread default ", 0,
+                 &show_thread_default_cmd_list, 0,
                  &show_thread_cmd_list);
 
   add_cmd ("pause", class_run, set_thread_pause_cmd, _("\
index 9899545a1e218d948db4632c336eb653b3ae6de3..5aae3405f6e1431d535626316c486d9e3646628b 100644 (file)
@@ -2099,7 +2099,7 @@ _initialize_go32_nat ()
 
   add_basic_prefix_cmd ("dos", class_info, _("\
 Print information specific to DJGPP (aka MS-DOS) debugging."),
-                       &info_dos_cmdlist, "info dos ", 0, &infolist);
+                       &info_dos_cmdlist, 0, &infolist);
 
   add_cmd ("sysinfo", class_info, go32_sysinfo, _("\
 Display information about the target system, including CPU, OS, DPMI, etc."),
index 71d61f375b35e3ffbf01d5229325f0c6ed252893..0166355b786b94116f321c0c3e8c7aae83f92892 100644 (file)
@@ -782,20 +782,17 @@ This command is only a placeholder.")
 
   add_basic_prefix_cmd ("guile", class_obscure,
                        _("Prefix command for Guile preference settings."),
-                       &set_guile_list, "set guile ", 0,
-                       &setlist);
+                       &set_guile_list, 0, &setlist);
   add_alias_cmd ("gu", "guile", class_obscure, 1, &setlist);
 
   add_show_prefix_cmd ("guile", class_obscure,
                       _("Prefix command for Guile preference settings."),
-                      &show_guile_list, "show guile ", 0,
-                      &showlist);
+                      &show_guile_list, 0, &showlist);
   add_alias_cmd ("gu", "guile", class_obscure, 1, &showlist);
 
   add_basic_prefix_cmd ("guile", class_obscure,
                        _("Prefix command for Guile info displays."),
-                       &info_guile_list, "info guile ", 0,
-                       &infolist);
+                       &info_guile_list, 0, &infolist);
   add_info_alias ("gu", "guile", 1);
 
   /* The name "print-stack" is carried over from Python.
index 1708d662b879a15efd2a73aa50acdc644cef3457..1f35d881a2d1e1dd9d1e486cd871d9c9fe1edca8 100644 (file)
@@ -766,7 +766,7 @@ gdbscm_register_command_x (SCM self)
 
          cmd = add_prefix_cmd (c_smob->cmd_name, c_smob->cmd_class,
                                NULL, c_smob->doc, &c_smob->sub_list,
-                               c_smob->name, allow_unknown, cmd_list);
+                               allow_unknown, cmd_list);
        }
       else
        {
index 50fd2767a18292a0dbc21222c8929c768acb835e..5e6769ae9130ef2abf83c9c66fd41b7c80436c84 100644 (file)
@@ -9031,14 +9031,14 @@ is \"default\"."),
 
   add_basic_prefix_cmd ("mpx", class_support, _("\
 Set Intel Memory Protection Extensions specific variables."),
-                       &mpx_set_cmdlist, "set mpx ",
+                       &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, "show mpx ",
+                      &mpx_show_cmdlist,
                       0 /* allow-unknown */, &showlist);
 
   /* Add "bound" command for the show mpx commands list.  */
index f0b044d62b946e28403c781ac25419632e656bf6..a22d815f2302a3b3fcd49503020975e7830bc5d4 100644 (file)
@@ -3084,7 +3084,7 @@ environment to be given to the program."), &showlist);
 
   add_basic_prefix_cmd ("unset", no_class,
                        _("Complement to certain \"set\" commands."),
-                       &unsetlist, "unset ", 0, &cmdlist);
+                       &unsetlist, 0, &cmdlist);
 
   c = add_cmd ("environment", class_run, unset_environment_command, _("\
 Cancel environment variable VAR for the program.\n\
@@ -3121,7 +3121,7 @@ needed."),
 
   add_prefix_cmd ("kill", class_run, kill_command,
                  _("Kill execution of program being debugged."),
-                 &killlist, "kill ", 0, &cmdlist);
+                 &killlist, 0, &cmdlist);
 
   add_com ("attach", class_run, attach_command, _("\
 Attach to a process or file outside of GDB.\n\
@@ -3140,7 +3140,7 @@ to specify the program, and to load its symbol table."));
 Detach a process or file previously attached.\n\
 If a process, it is no longer traced, and it continues its execution.  If\n\
 you were debugging a file, the file is closed and gdb no longer accesses it."),
-                 &detachlist, "detach ", 0, &cmdlist);
+                 &detachlist, 0, &cmdlist);
 
   add_com ("disconnect", class_run, disconnect_command, _("\
 Disconnect from a target.\n\
@@ -3295,7 +3295,7 @@ in the named register groups."));
                  _("\
 Show additional information about a process.\n\
 Specify any process id, or use the program being debugged by default."),
-                 &info_proc_cmdlist, "info proc ",
+                 &info_proc_cmdlist,
                  1/*allow-unknown*/, &infolist);
 
   add_cmd ("mappings", class_info, info_proc_cmd_mappings, _("\
index 4cb71d6dfb16beef5a9be65818ff0c56c253ce30..a3f96ecd6ff77bf607106775766ce2e229a14c72 100644 (file)
@@ -1166,13 +1166,13 @@ _initialize_language ()
 
   add_basic_prefix_cmd ("check", no_class,
                        _("Set the status of the type/range checker."),
-                       &setchecklist, "set check ", 0, &setlist);
+                       &setchecklist, 0, &setlist);
   add_alias_cmd ("c", "check", no_class, 1, &setlist);
   add_alias_cmd ("ch", "check", no_class, 1, &setlist);
 
   add_show_prefix_cmd ("check", no_class,
                       _("Show the status of the type/range checker."),
-                      &showchecklist, "show check ", 0, &showlist);
+                      &showchecklist, 0, &showlist);
   add_alias_cmd ("c", "check", no_class, 1, &showlist);
   add_alias_cmd ("ch", "check", no_class, 1, &showlist);
 
index d76792675b1d1f9a03cc944ae116b7549fc2a01b..4e4a68d5c1d55d8b6062a0430871847a1b907613 100644 (file)
@@ -455,7 +455,7 @@ _initialize_macrocmd ()
      the various commands for working with preprocessor macros.  */
   add_basic_prefix_cmd ("macro", class_info,
                        _("Prefix for commands dealing with C preprocessor macros."),
-                       &macrolist, "macro ", 0, &cmdlist);
+                       &macrolist, 0, &cmdlist);
 
   add_cmd ("expand", no_class, macro_expand_command, _("\
 Fully expand any C/C++ preprocessor macro invocations in EXPRESSION.\n\
index 16ecd1dd7e58b711810dcc65c285295af7269298..b773e759bb7c468b7ba0336d8782956ace3ea026 100644 (file)
@@ -422,8 +422,7 @@ _initialize_maint_test_options ()
                        _("\
 Generic command for testing the options infrastructure."),
                        &maintenance_test_options_list,
-                       "maintenance test-options ", 0,
-                       &maintenancelist);
+                       0, &maintenancelist);
 
   const auto def_group = make_test_options_options_def_group (nullptr);
 
index ca28fcf88aaf4833ee27a184e58c15d09064f558..0ce889055188055d29e0cf5909494f84aec45858 100644 (file)
@@ -89,7 +89,6 @@ _initialize_maint_test_settings ()
                        _("\
 Set GDB internal variables used for set/show command infrastructure testing."),
                        &maintenance_set_test_settings_list,
-                       "maintenance set test-settings ",
                        0/*allow-unknown*/,
                        &maintenance_set_cmdlist);
 
@@ -97,7 +96,6 @@ Set GDB internal variables used for set/show command infrastructure testing."),
                       _("\
 Show GDB internal variables used for set/show command infrastructure testing."),
                       &maintenance_show_test_settings_list,
-                      "maintenance show test-settings ",
                       0/*allow-unknown*/,
                       &maintenance_show_cmdlist);
 
index 7f505d07a6994d7f096044337a3c75c8597affc3..154bef55981121215e2f4b08bb4626256f938c19 100644 (file)
@@ -1137,14 +1137,14 @@ _initialize_maint_cmds ()
 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,
+                       &maintenancelist, 0,
                        &cmdlist);
 
   add_com_alias ("mt", "maintenance", class_maintenance, 1);
 
   add_basic_prefix_cmd ("info", class_maintenance, _("\
 Commands for showing internal info about the program being debugged."),
-                       &maintenanceinfolist, "maintenance info ", 0,
+                       &maintenanceinfolist, 0,
                        &maintenancelist);
   add_alias_cmd ("i", "info", class_maintenance, 1, &maintenancelist);
 
@@ -1183,25 +1183,25 @@ sectoins."),
 
   add_basic_prefix_cmd ("print", class_maintenance,
                        _("Maintenance command for printing GDB internal state."),
-                       &maintenanceprintlist, "maintenance print ", 0,
+                       &maintenanceprintlist, 0,
                        &maintenancelist);
 
   add_basic_prefix_cmd ("flush", class_maintenance,
                        _("Maintenance command for flushing GDB internal caches."),
-                       &maintenanceflushlist, "maintenance flush ", 0,
+                       &maintenanceflushlist, 0,
                        &maintenancelist);
 
   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 ",
+                       &maintenance_set_cmdlist,
                        0/*allow-unknown*/,
                        &maintenancelist);
 
   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 ",
+                      &maintenance_show_cmdlist,
                       0/*allow-unknown*/,
                       &maintenancelist);
 
@@ -1247,12 +1247,12 @@ This command has been moved to \"demangle\"."),
 
   add_prefix_cmd ("per-command", class_maintenance, set_per_command_cmd, _("\
 Per-command statistics settings."),
-                   &per_command_setlist, "maintenance set per-command ",
+                   &per_command_setlist,
                    1/*allow-unknown*/, &maintenance_set_cmdlist);
 
   add_show_prefix_cmd ("per-command", class_maintenance, _("\
 Show per-command statistics settings."),
-                      &per_command_showlist, "maintenance show per-command ",
+                      &per_command_showlist,
                       0/*allow-unknown*/, &maintenance_show_cmdlist);
 
   add_setshow_boolean_cmd ("time", class_maintenance,
@@ -1320,7 +1320,7 @@ Takes an optional file parameter."),
 
   add_basic_prefix_cmd ("check", class_maintenance, _("\
 Commands for checking internal gdb state."),
-                       &maintenancechecklist, "maintenance check ", 0,
+                       &maintenancechecklist, 0,
                        &maintenancelist);
 
   add_cmd ("translate-address", class_maintenance,
index 17de5839767107009a794ff8096abaf30848c7c6..e1c3931c26291c91f21db561f7c2bfeda18a9b21 100644 (file)
@@ -625,11 +625,11 @@ Do \"info mem\" to see current list of IDs."), &deletelist);
 
   add_basic_prefix_cmd ("mem", class_vars, _("\
 Memory regions settings."),
-                       &mem_set_cmdlist, "set mem ",
+                       &mem_set_cmdlist,
                        0/* allow-unknown */, &setlist);
   add_show_prefix_cmd ("mem", class_vars, _("\
 Memory regions settings."),
-                      &mem_show_cmdlist, "show mem  ",
+                      &mem_show_cmdlist,
                       0/* allow-unknown */, &showlist);
 
   add_setshow_boolean_cmd ("inaccessible-by-default", no_class,
index 61545aed86c30ba9bdb627a548ef128afae226c1..2fe83324738f98c200d878471a309edaf0b543cf 100644 (file)
@@ -8945,11 +8945,11 @@ _initialize_mips_tdep ()
   /* Add root prefix command for all "set mips"/"show mips" commands.  */
   add_basic_prefix_cmd ("mips", no_class,
                        _("Various MIPS specific commands."),
-                       &setmipscmdlist, "set mips ", 0, &setlist);
+                       &setmipscmdlist, 0, &setlist);
 
   add_show_prefix_cmd ("mips", no_class,
                       _("Various MIPS specific commands."),
-                      &showmipscmdlist, "show mips ", 0, &showlist);
+                      &showmipscmdlist, 0, &showlist);
 
   /* Allow the user to override the ABI.  */
   add_setshow_enum_cmd ("abi", class_obscure, mips_abi_strings,
@@ -8990,7 +8990,7 @@ and is updated automatically from ELF file flags if available."),
 
   add_basic_prefix_cmd ("mipsfpu", class_support,
                        _("Set use of MIPS floating-point coprocessor."),
-                       &mipsfpulist, "set mipsfpu ", 0, &setlist);
+                       &mipsfpulist, 0, &setlist);
   add_cmd ("single", class_support, set_mipsfpu_single_command,
           _("Select single-precision MIPS floating-point coprocessor."),
           &mipsfpulist);
index 1c68d19cda1fb63861591033c689908f6627cfb2..a5c03c3a830760f395588e674ef0ab147571eb9e 100644 (file)
@@ -3281,7 +3281,7 @@ Use \"set variable\" for variables with names identical to set subcommands.\n\
 \n\
 With a subcommand, this command modifies parts of the gdb environment.\n\
 You can see these environment settings with the \"show\" command."),
-                 &setlist, "set ", 1, &cmdlist);
+                 &setlist, 1, &cmdlist);
   if (dbx_commands)
     add_com ("assign", class_vars, set_command, _("\
 Evaluate expression EXP and assign result to variable VAR.\n\
@@ -3385,7 +3385,7 @@ treat this string as a command line, and evaluate it."));
   /* Memory tagging commands.  */
   add_prefix_cmd ("memory-tag", class_vars, memory_tag_command, _("\
 Generic command for printing and manipulating memory tag properties."),
-                 &memory_tag_list, "memory-tag ", 0, &cmdlist);
+                 &memory_tag_list, 0, &cmdlist);
   add_cmd ("print-logical-tag", class_vars,
           memory_tag_print_logical_tag_command,
           ("Print the logical tag from POINTER.\n\
index 0c4f22cf9f0fc0ec81bdd3e84904e006c7097ab6..9eccf82f25d994eb27f2be33954b17cb4bbdabd5 100644 (file)
@@ -788,8 +788,7 @@ If you specify TYPE, there may be additional arguments needed by the\n\
 subcommand.\n\
 If you do not specify any argument, or specify `all', then the command\n\
 will show information about all types of probes."),
-                   &info_probes_cmdlist, "info probes ",
-                   0/*allow-unknown*/, &infolist);
+                   &info_probes_cmdlist, 0/*allow-unknown*/, &infolist);
 
   return &info_probes_cmdlist;
 }
index f4d3dcc312182ba12161ea805a2bbb4d126d2c08..9833bf863b098aaf030e73e06f561f4115f2e707 100644 (file)
@@ -95,9 +95,6 @@ cmdpy_destroyer (struct cmd_list_element *self, void *context)
   /* Release our hold on the command object.  */
   gdbpy_ref<cmdpy_object> cmd ((cmdpy_object *) context);
   cmd->command = NULL;
-
-  /* We may have allocated the prefix name.  */
-  xfree ((char *) self->prefixname);
 }
 
 /* Called by gdb to invoke the command.  */
@@ -114,7 +111,7 @@ cmdpy_function (struct cmd_list_element *command,
     error (_("Invalid invocation of Python command object."));
   if (! PyObject_HasAttr ((PyObject *) obj, invoke_cst))
     {
-      if (obj->command->prefixname)
+      if (obj->command->prefixlist != nullptr)
        {
          /* A prefix command does not need an invoke method.  */
          return;
@@ -438,11 +435,11 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
   int completetype = -1;
   char *docstring = NULL;
   struct cmd_list_element **cmd_list;
-  char *cmd_name, *pfx_name;
+  char *cmd_name;
   static const char *keywords[] = { "name", "command_class", "completer_class",
                                    "prefix", NULL };
-  PyObject *is_prefix = NULL;
-  int cmp;
+  PyObject *is_prefix_obj = NULL;
+  bool is_prefix = false;
 
   if (obj->command)
     {
@@ -455,7 +452,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
 
   if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "si|iO",
                                        keywords, &name, &cmdtype,
-                                       &completetype, &is_prefix))
+                                       &completetype, &is_prefix_obj))
     return -1;
 
   if (cmdtype != no_class && cmdtype != class_run
@@ -481,39 +478,17 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
   if (! cmd_name)
     return -1;
 
-  pfx_name = NULL;
-  if (is_prefix != NULL)
+  if (is_prefix_obj != NULL)
     {
-      cmp = PyObject_IsTrue (is_prefix);
-      if (cmp == 1)
-       {
-         int i, out;
-       
-         /* Make a normalized form of the command name.  */
-         pfx_name = (char *) xmalloc (strlen (name) + 2);
-       
-         i = 0;
-         out = 0;
-         while (name[i])
-           {
-             /* Skip whitespace.  */
-             while (name[i] == ' ' || name[i] == '\t')
-               ++i;
-             /* Copy non-whitespace characters.  */
-             while (name[i] && name[i] != ' ' && name[i] != '\t')
-               pfx_name[out++] = name[i++];
-             /* Add a single space after each word -- including the final
-                word.  */
-             pfx_name[out++] = ' ';
-           }
-         pfx_name[out] = '\0';
-       }
-      else if (cmp < 0)
+      int cmp = PyObject_IsTrue (is_prefix_obj);
+       if (cmp < 0)
        {
          xfree (cmd_name);
          return -1;
        }
+       is_prefix = cmp > 0;
     }
+
   if (PyObject_HasAttr (self, gdbpy_doc_cst))
     {
       gdbpy_ref<> ds_obj (PyObject_GetAttr (self, gdbpy_doc_cst));
@@ -524,7 +499,6 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
          if (docstring == NULL)
            {
              xfree (cmd_name);
-             xfree (pfx_name);
              return -1;
            }
        }
@@ -538,7 +512,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
     {
       struct cmd_list_element *cmd;
 
-      if (pfx_name)
+      if (is_prefix)
        {
          int allow_unknown;
 
@@ -547,7 +521,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
          allow_unknown = PyObject_HasAttr (self, invoke_cst);
          cmd = add_prefix_cmd (cmd_name, (enum command_class) cmdtype,
                                NULL, docstring, &obj->sub_list,
-                               pfx_name, allow_unknown, cmd_list);
+                               allow_unknown, cmd_list);
        }
       else
        cmd = add_cmd (cmd_name, (enum command_class) cmdtype,
@@ -571,7 +545,6 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
     {
       xfree (cmd_name);
       xfree (docstring);
-      xfree (pfx_name);
       gdbpy_convert_exception (except);
       return -1;
     }
index c46d68b73ed56f50303fe1162cd384ad5a8e68f2..4cea83c38373dbd67b7a180317aaab0233ac1f50 100644 (file)
@@ -1936,13 +1936,11 @@ This command is only a placeholder.")
   /* Add set/show python print-stack.  */
   add_basic_prefix_cmd ("python", no_class,
                        _("Prefix command for python preference settings."),
-                       &user_show_python_list, "show python ", 0,
-                       &showlist);
+                       &user_show_python_list, 0, &showlist);
 
   add_show_prefix_cmd ("python", no_class,
                       _("Prefix command for python preference settings."),
-                      &user_set_python_list, "set python ", 0,
-                      &setlist);
+                      &user_set_python_list, 0, &setlist);
 
   add_setshow_enum_cmd ("print-stack", no_class, python_excp_enums,
                        &gdbpy_should_print_stack, _("\
index 84a0390ac7ce5475c754aa900cbb043c627e36b5..490af3a0bb47becc0d0e83d6432e2a6d29cd9608 100644 (file)
@@ -719,11 +719,11 @@ _initialize_ravenscar ()
 
   add_basic_prefix_cmd ("ravenscar", no_class,
                        _("Prefix command for changing Ravenscar-specific settings."),
-                       &set_ravenscar_list, "set ravenscar ", 0, &setlist);
+                       &set_ravenscar_list, 0, &setlist);
 
   add_show_prefix_cmd ("ravenscar", no_class,
                       _("Prefix command for showing Ravenscar-specific settings."),
-                      &show_ravenscar_list, "show ravenscar ", 0, &showlist);
+                      &show_ravenscar_list, 0, &showlist);
 
   add_setshow_boolean_cmd ("task-switching", class_obscure,
                           &ravenscar_task_support, _("\
index c888ad0cb248f370c5c2ae661b6a00108eeb423e..c04e1cde72181ec8c6e2ff022421bc6288c2fdff 100644 (file)
@@ -3111,7 +3111,7 @@ _initialize_record_btrace ()
 {
   add_prefix_cmd ("btrace", class_obscure, cmd_record_btrace_start,
                  _("Start branch trace recording."), &record_btrace_cmdlist,
-                 "record btrace ", 0, &record_cmdlist);
+                 0, &record_cmdlist);
   add_alias_cmd ("b", "btrace", class_obscure, 1, &record_cmdlist);
 
   add_cmd ("bts", class_obscure, cmd_record_btrace_bts_start,
@@ -3131,11 +3131,11 @@ This format may not be available on all processors."),
 
   add_basic_prefix_cmd ("btrace", class_support,
                        _("Set record options."), &set_record_btrace_cmdlist,
-                       "set record btrace ", 0, &set_record_cmdlist);
+                       0, &set_record_cmdlist);
 
   add_show_prefix_cmd ("btrace", class_support,
                       _("Show record options."), &show_record_btrace_cmdlist,
-                      "show record btrace ", 0, &show_record_cmdlist);
+                      0, &show_record_cmdlist);
 
   add_setshow_enum_cmd ("replay-memory-access", no_class,
                        replay_memory_access_types, &replay_memory_access, _("\
@@ -3163,7 +3163,7 @@ When GDB does not support that cpu, this option can be used to enable\n\
 workarounds for a similar cpu that GDB supports.\n\n\
 When set to \"none\", errata workarounds are disabled."),
                  &set_record_btrace_cpu_cmdlist,
-                 "set record btrace cpu ", 1,
+                 1,
                  &set_record_btrace_cmdlist);
 
   add_cmd ("auto", class_support, cmd_set_record_btrace_cpu_auto, _("\
@@ -3181,13 +3181,13 @@ Show the cpu to be used for trace decode."),
   add_basic_prefix_cmd ("bts", class_support,
                        _("Set record btrace bts options."),
                        &set_record_btrace_bts_cmdlist,
-                       "set record btrace bts ", 0,
+                       0,
                        &set_record_btrace_cmdlist);
 
   add_show_prefix_cmd ("bts", class_support,
                       _("Show record btrace bts options."),
                       &show_record_btrace_bts_cmdlist,
-                      "show record btrace bts ", 0,
+                      0,
                       &show_record_btrace_cmdlist);
 
   add_setshow_uinteger_cmd ("buffer-size", no_class,
@@ -3207,13 +3207,13 @@ The trace buffer size may not be changed while recording."), NULL,
   add_basic_prefix_cmd ("pt", class_support,
                        _("Set record btrace pt options."),
                        &set_record_btrace_pt_cmdlist,
-                       "set record btrace pt ", 0,
+                       0,
                        &set_record_btrace_cmdlist);
 
   add_show_prefix_cmd ("pt", class_support,
                       _("Show record btrace pt options."),
                       &show_record_btrace_pt_cmdlist,
-                      "show record btrace pt ", 0,
+                      0,
                       &show_record_btrace_cmdlist);
 
   add_setshow_uinteger_cmd ("buffer-size", no_class,
index 8a035b2663eab04926184fa744a07d952f1df147..91da1076194ffb16735f1646af3bb9d8bf45b67a 100644 (file)
@@ -2794,7 +2794,7 @@ _initialize_record_full ()
 
   add_prefix_cmd ("full", class_obscure, cmd_record_full_start,
                  _("Start full execution recording."), &record_full_cmdlist,
-                 "record full ", 0, &record_cmdlist);
+                 0, &record_cmdlist);
 
   c = add_cmd ("restore", class_obscure, cmd_record_full_restore,
               _("Restore the execution log from a file.\n\
@@ -2810,11 +2810,11 @@ Argument is filename.  File must be created with 'record save'."),
 
   add_basic_prefix_cmd ("full", class_support,
                        _("Set record options."), &set_record_full_cmdlist,
-                       "set record full ", 0, &set_record_cmdlist);
+                       0, &set_record_cmdlist);
 
   add_show_prefix_cmd ("full", class_support,
                       _("Show record options."), &show_record_full_cmdlist,
-                      "show record full ", 0, &show_record_cmdlist);
+                      0, &show_record_cmdlist);
 
   /* Record instructions number limit command.  */
   add_setshow_boolean_cmd ("stop-at-limit", no_class,
index 483b906c2d06c706f8418a92a00a3a15b445da8a..7dae18f77b4f3d6c4798558f3c4fe292aab946c8 100644 (file)
@@ -787,21 +787,21 @@ A size of \"unlimited\" means unlimited lines.  The default is 10."),
 
   c = add_prefix_cmd ("record", class_obscure, cmd_record_start,
                      _("Start recording."),
-                     &record_cmdlist, "record ", 0, &cmdlist);
+                     &record_cmdlist, 0, &cmdlist);
   set_cmd_completer (c, filename_completer);
 
   add_com_alias ("rec", "record", class_obscure, 1);
   add_basic_prefix_cmd ("record", class_support,
                        _("Set record options."), &set_record_cmdlist,
-                       "set record ", 0, &setlist);
+                       0, &setlist);
   add_alias_cmd ("rec", "record", class_obscure, 1, &setlist);
   add_show_prefix_cmd ("record", class_support,
                       _("Show record options."), &show_record_cmdlist,
-                      "show record ", 0, &showlist);
+                      0, &showlist);
   add_alias_cmd ("rec", "record", class_obscure, 1, &showlist);
   add_prefix_cmd ("record", class_support, info_record_command,
                  _("Info record options."), &info_record_cmdlist,
-                 "info record ", 0, &infolist);
+                 0, &infolist);
   add_alias_cmd ("rec", "record", class_obscure, 1, &infolist);
 
   c = add_cmd ("save", class_obscure, cmd_record_save,
@@ -825,7 +825,7 @@ Default filename is 'gdb_record.PROCESS_ID'."),
   add_prefix_cmd ("goto", class_obscure, cmd_record_goto, _("\
 Restore the program to its state at instruction number N.\n\
 Argument is instruction number, as shown by 'info record'."),
-                 &record_goto_cmdlist, "record goto ", 1, &record_cmdlist);
+                 &record_goto_cmdlist, 1, &record_cmdlist);
 
   add_cmd ("begin", class_obscure, cmd_record_goto_begin,
           _("Go to the beginning of the execution log."),
index d3a66599122c105a4ca9a8d2853a03255558de95..8411b29d7345b0e2c07d96bb3a261c41e181e585 100644 (file)
@@ -14854,13 +14854,13 @@ _initialize_remote ()
 Remote protocol specific variables.\n\
 Configure various remote-protocol specific variables such as\n\
 the packets being used."),
-                       &remote_set_cmdlist, "set remote ",
+                       &remote_set_cmdlist,
                        0 /* allow-unknown */, &setlist);
   add_prefix_cmd ("remote", class_maintenance, show_remote_cmd, _("\
 Remote protocol specific variables.\n\
 Configure various remote-protocol specific variables such as\n\
 the packets being used."),
-                 &remote_show_cmdlist, "show remote ",
+                 &remote_show_cmdlist,
                  0 /* allow-unknown */, &showlist);
 
   add_cmd ("compare-sections", class_obscure, compare_sections_command, _("\
@@ -15282,7 +15282,7 @@ packets."),
   add_basic_prefix_cmd ("remote", class_files, _("\
 Manipulate files on the remote system.\n\
 Transfer files to and from the remote target system."),
-                       &remote_cmdlist, "remote ",
+                       &remote_cmdlist,
                        0 /* allow-unknown */, &cmdlist);
 
   add_cmd ("put", class_files, remote_put_command,
index c17839968465e4fd8b4a0bb8a6f7b6e0bc7aac14..7fae91401553df10ac38936cb1a167aee9695b44 100644 (file)
@@ -3850,12 +3850,12 @@ _initialize_riscv_tdep ()
      riscv" commands.  */
   add_basic_prefix_cmd ("riscv", no_class,
                        _("RISC-V specific debug commands."),
-                       &setdebugriscvcmdlist, "set debug riscv ", 0,
+                       &setdebugriscvcmdlist, 0,
                        &setdebuglist);
 
   add_show_prefix_cmd ("riscv", no_class,
                       _("RISC-V specific debug commands."),
-                      &showdebugriscvcmdlist, "show debug riscv ", 0,
+                      &showdebugriscvcmdlist, 0,
                       &showdebuglist);
 
   add_setshow_zuinteger_cmd ("breakpoints", class_maintenance,
@@ -3901,11 +3901,11 @@ initialisation process."),
   /* Add root prefix command for all "set riscv" and "show riscv" commands.  */
   add_basic_prefix_cmd ("riscv", no_class,
                        _("RISC-V specific commands."),
-                       &setriscvcmdlist, "set riscv ", 0, &setlist);
+                       &setriscvcmdlist, 0, &setlist);
 
   add_show_prefix_cmd ("riscv", no_class,
                       _("RISC-V specific commands."),
-                      &showriscvcmdlist, "show riscv ", 0, &showlist);
+                      &showriscvcmdlist, 0, &showlist);
 
 
   use_compressed_breakpoints = AUTO_BOOLEAN_AUTO;
index 347014d6c2f3a244d66bce9ca8a0ee0f680ca207..57dbe5b3273c4a2a4009d8d6ffa780f2ddddc7b9 100644 (file)
@@ -7402,11 +7402,11 @@ _initialize_rs6000_tdep ()
      commands.  */
   add_basic_prefix_cmd ("powerpc", no_class,
                        _("Various PowerPC-specific commands."),
-                       &setpowerpccmdlist, "set powerpc ", 0, &setlist);
+                       &setpowerpccmdlist, 0, &setlist);
 
   add_show_prefix_cmd ("powerpc", no_class,
                       _("Various PowerPC-specific commands."),
-                      &showpowerpccmdlist, "show powerpc ", 0, &showlist);
+                      &showpowerpccmdlist, 0, &showlist);
 
   /* Add a command to allow the user to force the ABI.  */
   add_setshow_auto_boolean_cmd ("soft-float", class_support,
index e79c9e6573de73e6823548575e04c4d22d6d94e2..2519caa505c0512768a51eea0052d4127b334598 100644 (file)
@@ -469,12 +469,12 @@ _initialize_ser_tcp ()
   add_basic_prefix_cmd ("tcp", class_maintenance, _("\
 TCP protocol specific variables.\n\
 Configure variables specific to remote TCP connections."),
-                       &tcp_set_cmdlist, "set tcp ",
+                       &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, "show tcp ",
+                      &tcp_show_cmdlist,
                       0 /* allow-unknown */, &showlist);
 
   add_setshow_boolean_cmd ("auto-retry", class_obscure,
index 1854721d7ed601292f9a9fbb5069ad24b9a17823..719cd66c08cf7abbb69f1085d91e34db3218da9c 100644 (file)
@@ -671,13 +671,13 @@ Use <CR>~. or <CR>~^D to break out."));
 
   add_basic_prefix_cmd ("serial", class_maintenance, _("\
 Set default serial/parallel port configuration."),
-                       &serial_set_cmdlist, "set serial ",
+                       &serial_set_cmdlist,
                        0/*allow-unknown*/,
                        &setlist);
 
   add_show_prefix_cmd ("serial", class_maintenance, _("\
 Show default serial/parallel port configuration."),
-                      &serial_show_cmdlist, "show serial ",
+                      &serial_show_cmdlist,
                       0/*allow-unknown*/,
                       &showlist);
 
index 5a71d3ac6896c25cbce5e22e5c532442d612c295..31d912db018dddb6cd85b1a662a2c4e4d9c8d5f6 100644 (file)
@@ -2415,9 +2415,9 @@ _initialize_sh_tdep ()
   gdbarch_register (bfd_arch_sh, sh_gdbarch_init, NULL);
 
   add_basic_prefix_cmd ("sh", no_class, "SH specific commands.",
-                       &setshcmdlist, "set sh ", 0, &setlist);
+                       &setshcmdlist, 0, &setlist);
   add_show_prefix_cmd ("sh", no_class, "SH specific commands.",
-                      &showshcmdlist, "show sh ", 0, &showlist);
+                      &showshcmdlist, 0, &showlist);
   
   add_setshow_enum_cmd ("calling-convention", class_vars, sh_cc_enum,
                        &sh_active_calling_convention,
index eeb5715546e89df2849cc2a14a3be75cb10117af..4d24088f2474db19d39e8663473b894258619d8a 100644 (file)
@@ -676,7 +676,7 @@ FILE-SPEC is one of:\n\
 FUNCTION-SPEC is one of:\n\
        -fu|-function FUNCTION-NAME\n\
        -rfu|-rfunction FUNCTION-NAME-REGULAR-EXPRESSION"),
-                 &skiplist, "skip ", 1, &cmdlist);
+                 &skiplist, 1, &cmdlist);
 
   c = add_cmd ("file", class_breakpoint, skip_file_command, _("\
 Ignore a file while stepping.\n\
index 3609794419ab549797f08d12581ff05e73ba7e35..3f9600f387938026e8545d230c2b8806d912c478 100644 (file)
@@ -534,7 +534,7 @@ _initialize_sparc64_adi_tdep ()
 {
   add_basic_prefix_cmd ("adi", class_support,
                        _("ADI version related commands."),
-                       &sparc64adilist, "adi ", 0, &cmdlist);
+                       &sparc64adilist, 0, &cmdlist);
   add_cmd ("examine", class_support, adi_examine_command,
           _("Examine ADI versions."), &sparc64adilist);
   add_alias_cmd ("x", "examine", no_class, 1, &sparc64adilist);
index bce6a2f42f86004012a0829944d0f9b8add0a0a1..7856a5a817657013bd2ab8287b567b4b2eee2b9f 100644 (file)
@@ -3343,7 +3343,7 @@ This is useful in command scripts."));
 Select and print a stack frame.\n\
 With no argument, print the selected stack frame.  (See also \"info frame\").\n\
 A single numerical argument specifies the frame to select."),
-                 &frame_cmd_list, "frame ", 1, &cmdlist);
+                 &frame_cmd_list, 1, &cmdlist);
   add_com_alias ("f", "frame", class_stack, 1);
 
 #define FRAME_APPLY_OPTION_HELP "\
@@ -3367,7 +3367,7 @@ With a negative COUNT argument, applies the command on outermost -COUNT frames.\
 
   cmd = add_prefix_cmd ("apply", class_stack, frame_apply_command,
                        frame_apply_cmd_help.c_str (),
-                       &frame_apply_cmd_list, "frame apply ", 1,
+                       &frame_apply_cmd_list, 1,
                        &frame_cmd_list);
   set_cmd_completer_handle_brkchars (cmd, frame_apply_cmd_completer);
 
@@ -3440,7 +3440,7 @@ Usage: frame level LEVEL"),
                      &select_frame_cmd.base_command, _("\
 Select a stack frame without printing anything.\n\
 A single numerical argument specifies the frame to select."),
-                     &select_frame_cmd_list, "select-frame ", 1, &cmdlist,
+                     &select_frame_cmd_list, 1, &cmdlist,
                      &cli_suppress_notification.user_selected_context);
 
   add_cmd_suppress_notification ("address", class_stack,
@@ -3515,7 +3515,7 @@ With a negative COUNT, print outermost -COUNT frames."),
 With no arguments, displays information about the currently selected stack\n\
 frame.  Alternatively a frame specification may be provided (See \"frame\")\n\
 the information is then printed about the specified frame."),
-                 &info_frame_cmd_list, "info frame ", 1, &infolist);
+                 &info_frame_cmd_list, 1, &infolist);
   add_info_alias ("f", "frame", 1);
 
   add_cmd ("address", class_stack, &info_frame_cmd.address,
index 5defc22870d66b8913c611c60a3e26897ed0252d..4ba695360fbcff9c1848c79a04fb1366775cc427 100644 (file)
@@ -3865,7 +3865,7 @@ on its own."), &cmdlist);
 
   add_basic_prefix_cmd ("overlay", class_support,
                        _("Commands for debugging overlays."), &overlaylist,
-                       "overlay ", 0, &cmdlist);
+                       0, &cmdlist);
 
   add_com_alias ("ovly", "overlay", class_support, 1);
   add_com_alias ("ov", "overlay", class_support, 1);
index 061177e1d238d0c7c7d3947bcfd389ae8de67689..9555f94707de526144e0586dcafa5b2602b53a41 100644 (file)
@@ -6799,8 +6799,7 @@ Options:\n\
 
   add_basic_prefix_cmd ("module", class_info, _("\
 Print information about modules."),
-                       &info_module_cmdlist, "info module ",
-                       0, &infolist);
+                       &info_module_cmdlist, 0, &infolist);
 
   c = add_cmd ("functions", class_info, info_module_functions_command, _("\
 Display functions arranged by modules.\n\
index 053864dec58bdef17a7ea8901cb89b7e9a7d001a..f7d0a688c62f884be049e6c7d8b3b4445e40609e 100644 (file)
@@ -1966,15 +1966,15 @@ _initialize_target_descriptions ()
 
   add_basic_prefix_cmd ("tdesc", class_maintenance, _("\
 Set target description specific variables."),
-                       &tdesc_set_cmdlist, "set tdesc ",
+                       &tdesc_set_cmdlist,
                        0 /* allow-unknown */, &setlist);
   add_show_prefix_cmd ("tdesc", class_maintenance, _("\
 Show target description specific variables."),
-                      &tdesc_show_cmdlist, "show tdesc ",
+                      &tdesc_show_cmdlist,
                       0 /* allow-unknown */, &showlist);
   add_basic_prefix_cmd ("tdesc", class_maintenance, _("\
 Unset target description specific variables."),
-                       &tdesc_unset_cmdlist, "unset tdesc ",
+                       &tdesc_unset_cmdlist,
                        0 /* allow-unknown */, &unsetlist);
 
   add_setshow_filename_cmd ("filename", class_obscure,
index 78327a2a6c338423008d3562e8ab51d67b49d0af..438788e6e62de81ed85fb8cff0a89b7dde22c8fb 100644 (file)
@@ -872,7 +872,7 @@ The first argument is the type or protocol of the target machine.\n\
 Remaining arguments are interpreted by the target protocol.  For more\n\
 information on the arguments for a particular protocol, type\n\
 `help target ' followed by the protocol name."),
-                         &targetlist, "target ", 0, &cmdlist);
+                         &targetlist, 0, &cmdlist);
   c = add_cmd (t.shortname, no_class, t.doc, &targetlist);
   set_cmd_context (c, (void *) &t);
   set_cmd_sfunc (c, open_target);
index fc6db96fbcb80525d7b94a370192bf76b96b856b..3cd588e0b121b68ee166990283ffcfe201a397f0 100644 (file)
@@ -2137,7 +2137,7 @@ Options:\n\
   add_prefix_cmd ("thread", class_run, thread_command, _("\
 Use this command to switch between threads.\n\
 The new thread ID must be currently known."),
-                 &thread_cmd_list, "thread ", 1, &cmdlist);
+                 &thread_cmd_list, 1, &cmdlist);
 
 #define THREAD_APPLY_OPTION_HELP "\
 Prints per-inferior thread number and target system's thread id\n\
@@ -2160,7 +2160,7 @@ THREAD_APPLY_OPTION_HELP),
 
   c = add_prefix_cmd ("apply", class_run, thread_apply_command,
                      thread_apply_help.c_str (),
-                     &thread_apply_list, "thread apply ", 1,
+                     &thread_apply_list, 1,
                      &thread_cmd_list);
   set_cmd_completer_handle_brkchars (c, thread_apply_command_completer);
 
index a83d16bed1571e0355f7db647979c838a8c73fa0..2eb68fd2bc0e0103e7e164d6194630f3de8e5b0a 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -653,10 +653,14 @@ execute_command (const char *p, int from_tty)
           that can be followed by its args), report the list of
           subcommands.  */
        {
+         std::string prefixname = c->prefixname ();
+          std::string prefixname_no_space
+           = prefixname.substr (0, prefixname.length () - 1);
          printf_unfiltered
-           ("\"%.*s\" must be followed by the name of a subcommand.\n",
-            (int) strlen (c->prefixname) - 1, c->prefixname);
-         help_list (*c->prefixlist, c->prefixname, all_commands, gdb_stdout);
+           ("\"%s\" must be followed by the name of a subcommand.\n",
+            prefixname_no_space.c_str ());
+         help_list (*c->prefixlist, prefixname.c_str (), all_commands,
+                    gdb_stdout);
        }
       else if (c->type == set_cmd)
        do_set_command (arg, from_tty, c);
index 48d72d6a1f280bf17d2c97d50e6464354c3708f1..7f6d3e4a16be52d8a8da87e5d8da415bb76b9b42 100644 (file)
@@ -4046,7 +4046,7 @@ List target static tracepoints markers."));
   add_prefix_cmd ("tfind", class_trace, tfind_command, _("\
 Select a trace frame.\n\
 No argument means forward by one frame; '-' means backward by one frame."),
-                 &tfindlist, "tfind ", 1, &cmdlist);
+                 &tfindlist, 1, &cmdlist);
 
   add_cmd ("outside", class_trace, tfind_outside_command, _("\
 Select a trace frame whose PC is outside the given range (exclusive).\n\
index bf9c3ff4ddc5524eba009bbef93c5c070cfb9af4..b54e748194576de1cc249a485cd9c81d1c423bec 100644 (file)
@@ -1022,7 +1022,7 @@ _initialize_tui_layout ()
   add_basic_prefix_cmd ("layout", class_tui, _("\
 Change the layout of windows.\n\
 Usage: layout prev | next | LAYOUT-NAME"),
-                       &layout_list, "layout ", 0, &cmdlist);
+                       &layout_list, 0, &cmdlist);
 
   add_cmd ("next", class_tui, tui_next_layout_command,
           _("Apply the next TUI layout."),
index 17682b022a3a6df06292652dfa53d2830238ffcb..f036127b018c7ef3591f08ee2228a274ccaf2577 100644 (file)
@@ -306,7 +306,7 @@ tui_get_cmd_list (void)
   if (tuilist == 0)
     add_basic_prefix_cmd ("tui", class_tui,
                          _("Text User Interface commands."),
-                         &tuilist, "tui ", 0, &cmdlist);
+                         &tuilist, 0, &cmdlist);
   return &tuilist;
 }
 
@@ -996,12 +996,10 @@ _initialize_tui_win ()
      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, "set tui ",
-                       0 /* allow-unknown */, &setlist);
+                       &tui_setlist, 0 /* allow-unknown */, &setlist);
   add_show_prefix_cmd ("tui", class_tui,
                       _("TUI configuration variables."),
-                      &tui_showlist, "show tui ",
-                      0 /* allow-unknown */, &showlist);
+                      &tui_showlist, 0 /* allow-unknown */, &showlist);
 
   add_com ("refresh", class_tui, tui_refresh_all_command,
           _("Refresh the terminal display."));
index eb47d9129f9bd6bddd1c5961d1f353a13ca20b88..0776f634215b99278cd526d52ebb32ce4b03941d 100644 (file)
@@ -847,12 +847,10 @@ Only one level of typedefs is unrolled.  See also \"ptype\"."));
 
   add_show_prefix_cmd ("type", no_class,
                       _("Generic command for showing type-printing settings."),
-                      &showprinttypelist, "show print type ", 0,
-                      &showprintlist);
+                      &showprinttypelist, 0, &showprintlist);
   add_basic_prefix_cmd ("type", no_class,
                        _("Generic command for setting how types print."),
-                       &setprinttypelist, "set print type ", 0,
-                       &setprintlist);
+                       &setprinttypelist, 0, &setprintlist);
 
   add_setshow_boolean_cmd ("methods", no_class, &print_methods,
                           _("\
index e6aadf3124fabcd34b29ccc412e907987e765fea..040e22b93909ad30fea077971010b56d098453db 100644 (file)
@@ -87,7 +87,7 @@ check_doc (struct cmd_list_element *commandlist, const char *prefix)
        {
          /* Recursively call ourselves on the subcommand list,
             passing the right prefix in.  */
-         check_doc (*c->prefixlist, c->prefixname);
+         check_doc (*c->prefixlist, c->prefixname ().c_str ());
        }
     }
 }
@@ -159,7 +159,7 @@ traverse_command_structure (struct cmd_list_element **list,
        {
          /* Recursively call ourselves on the subcommand list,
             passing the right prefix in.  */
-         traverse_command_structure (c->prefixlist, c->prefixname);
+         traverse_command_structure (c->prefixlist, c->prefixname ().c_str ());
        }
       if (prefixcmd != c->prefix
          || (prefixcmd == nullptr && *list != cmdlist))
index 1f48a5a0bfea5e8ecde4c7138771dce5ee057832..c59c63565eb1f93ce9c272aa9d893dffad9c8bc2 100644 (file)
@@ -506,14 +506,10 @@ add_internal_problem_command (struct internal_problem *problem)
 
   add_basic_prefix_cmd (problem->name, class_maintenance, set_doc,
                        set_cmd_list,
-                       concat ("maintenance set ", problem->name, " ",
-                               (char *) NULL),
                        0/*allow-unknown*/, &maintenance_set_cmdlist);
 
   add_show_prefix_cmd (problem->name, class_maintenance, show_doc,
                       show_cmd_list,
-                      concat ("maintenance show ", problem->name, " ",
-                              (char *) NULL),
                       0/*allow-unknown*/, &maintenance_show_cmdlist);
 
   if (problem->user_settable_should_quit)
index 654552aa42e2a143be413530668fd81e3207e64a..e191c357fcaecbc2e0a5ebe101cbdcd1d6a291ee 100644 (file)
@@ -3145,28 +3145,26 @@ _initialize_valprint ()
 
   add_basic_prefix_cmd ("print", no_class,
                        _("Generic command for setting how things print."),
-                       &setprintlist, "set print ", 0, &setlist);
+                       &setprintlist, 0, &setlist);
   add_alias_cmd ("p", "print", no_class, 1, &setlist);
   /* Prefer set print to set prompt.  */
   add_alias_cmd ("pr", "print", no_class, 1, &setlist);
 
   add_show_prefix_cmd ("print", no_class,
                       _("Generic command for showing print settings."),
-                      &showprintlist, "show print ", 0, &showlist);
+                      &showprintlist, 0, &showlist);
   add_alias_cmd ("p", "print", no_class, 1, &showlist);
   add_alias_cmd ("pr", "print", no_class, 1, &showlist);
 
   cmd = add_basic_prefix_cmd ("raw", no_class,
                              _("\
 Generic command for setting what things to print in \"raw\" mode."),
-                             &setprintrawlist, "set print raw ", 0,
-                             &setprintlist);
+                             &setprintrawlist, 0, &setprintlist);
   deprecate_cmd (cmd, nullptr);
 
   cmd = add_show_prefix_cmd ("raw", no_class,
                             _("Generic command for showing \"print raw\" settings."),
-                            &showprintrawlist, "show print raw ", 0,
-                            &showprintlist);
+                            &showprintrawlist, 0, &showprintlist);
   deprecate_cmd (cmd, nullptr);
 
   gdb::option::add_setshow_cmds_for_options
index 3bd81e76007c4795faadf85241e9ea6496a57026..9822cec209b250af7a89a64277abea33b87cdbfb 100644 (file)
@@ -4259,7 +4259,7 @@ VARIABLE is already initialized."));
 
   add_prefix_cmd ("function", no_class, function_command, _("\
 Placeholder command for showing help on convenience functions."),
-                 &functionlist, "function ", 0, &cmdlist);
+                 &functionlist, 0, &cmdlist);
 
   add_internal_function ("_isvoid", _("\
 Check whether an expression is void.\n\
index 97aa3da6e777e625a9574bb2925a0dea1758e981..e6644843a95127681fdbab169372a940ad2b643e 100644 (file)
@@ -616,7 +616,7 @@ init_w32_command_list (void)
       add_basic_prefix_cmd
        ("w32", class_info,
         _("Print information specific to Win32 debugging."),
-        &info_w32_cmdlist, "info w32 ", 0, &infolist);
+        &info_w32_cmdlist, 0, &infolist);
       w32_prefix_command_valid = 1;
     }
 }