From 14b42fc4a0edc412e02a6c9cfe7eb48e67da3145 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 17 May 2021 14:01:08 -0400 Subject: [PATCH] gdb: rename cmd_list_element::prefixlist to subcommands While browsing this code, I found the name "prefixlist" really confusing. I kept reading it as "list of prefixes". Which it isn't: it's a list of sub-commands, for a prefix command. I think that renaming it to "subcommands" would make things clearer. gdb/ChangeLog: * Rename "prefixlist" parameters to "subcommands" throughout. * cli/cli-decode.h (cmd_list_element) : Rename to... : ... this. * cli/cli-decode.c (lookup_cmd_for_prefixlist): Rename to... (lookup_cmd_with_subcommands): ... this. Change-Id: I150da10d03052c2420aa5b0dee41f422e2a97928 --- gdb/ChangeLog | 8 +++ gdb/auto-load.c | 2 +- gdb/cli/cli-cmds.c | 6 +- gdb/cli/cli-decode.c | 91 +++++++++++++-------------- gdb/cli/cli-decode.h | 2 +- gdb/cli/cli-script.c | 30 ++++----- gdb/cli/cli-setshow.c | 10 +-- gdb/command.h | 2 +- gdb/completer.c | 8 +-- gdb/guile/scm-cmd.c | 4 +- gdb/python/py-cmd.c | 6 +- gdb/top.c | 4 +- gdb/unittests/command-def-selftests.c | 8 +-- 13 files changed, 94 insertions(+), 87 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4ff50087f75..4184c9f1ff8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2021-05-17 Simon Marchi + + * Rename "prefixlist" parameters to "subcommands" throughout. + * cli/cli-decode.h (cmd_list_element) : Rename to... + : ... this. + * cli/cli-decode.c (lookup_cmd_for_prefixlist): Rename to... + (lookup_cmd_with_subcommands): ... this. + 2021-05-17 Simon Marchi * cli/cli-decode.c (add_alias_cmd): Don't handle old == 0. diff --git a/gdb/auto-load.c b/gdb/auto-load.c index b9478c45c53..7745aa65b03 100644 --- a/gdb/auto-load.c +++ b/gdb/auto-load.c @@ -1465,7 +1465,7 @@ info_auto_load_cmd (const char *args, int from_tty) { ui_out_emit_tuple option_emitter (uiout, "option"); - gdb_assert (!list->prefixlist); + gdb_assert (!list->subcommands); gdb_assert (list->type == not_set_cmd); uiout->field_string ("name", list->name); diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 284b7519258..c29e5979acb 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -1625,7 +1625,7 @@ show_user (const char *args, int from_tty) { for (c = cmdlist; c; c = c->next) { - if (cli_user_command_p (c) || c->prefixlist != NULL) + if (cli_user_command_p (c) || c->subcommands != NULL) show_user_1 (c, "", c->name, gdb_stdout); } } @@ -1900,7 +1900,7 @@ alias_command (const char *args, int from_tty) /* We've already tried to look up COMMAND. */ gdb_assert (c_command != NULL && c_command != (struct cmd_list_element *) -1); - gdb_assert (c_command->prefixlist != NULL); + gdb_assert (c_command->subcommands != NULL); c_alias = lookup_cmd_1 (& alias_prefix, cmdlist, NULL, NULL, 1); if (c_alias != c_command) error (_("ALIAS and COMMAND prefixes do not match.")); @@ -1909,7 +1909,7 @@ alias_command (const char *args, int from_tty) alias_cmd = add_alias_cmd (xstrdup (alias_argv[alias_argc - 1]), command_argv[command_argc - 1], class_alias, a_opts.abbrev_flag, - c_command->prefixlist); + c_command->subcommands); } gdb_assert (alias_cmd != nullptr); diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 1bfc9477905..27bd311e89c 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -56,12 +56,12 @@ static int lookup_cmd_composition_1 (const char *text, struct cmd_list_element **cmd, struct cmd_list_element *cur_list); -/* Look up a command whose 'prefixlist' is KEY. Return the command if found, - otherwise return NULL. */ +/* Look up a command whose 'subcommands' field is SUBCOMMANDS. Return the + command if found, otherwise return NULL. */ static struct cmd_list_element * -lookup_cmd_for_prefixlist (struct cmd_list_element **key, - struct cmd_list_element *list) +lookup_cmd_with_subcommands (cmd_list_element **subcommands, + cmd_list_element *list) { struct cmd_list_element *p = NULL; @@ -69,16 +69,16 @@ lookup_cmd_for_prefixlist (struct cmd_list_element **key, { struct cmd_list_element *q; - if (p->prefixlist == NULL) + if (p->subcommands == NULL) continue; - else if (p->prefixlist == key) + else if (p->subcommands == subcommands) { /* If we found an alias, we must return the aliased command. */ return p->cmd_pointer ? p->cmd_pointer : p; } - q = lookup_cmd_for_prefixlist (key, *(p->prefixlist)); + q = lookup_cmd_with_subcommands (subcommands, *(p->subcommands)); if (q != NULL) return q; } @@ -163,7 +163,7 @@ set_cmd_completer_handle_brkchars (struct cmd_list_element *cmd, std::string cmd_list_element::prefixname () const { - if (this->prefixlist == nullptr) + if (this->subcommands == nullptr) /* Not a prefix command. */ return ""; @@ -236,8 +236,7 @@ do_add_cmd (const char *name, enum command_class theclass, /* Search the prefix cmd of C, and assigns it to C->prefix. See also add_prefix_cmd and update_prefix_field_of_prefixed_commands. */ - struct cmd_list_element *prefixcmd = lookup_cmd_for_prefixlist (list, - cmdlist); + cmd_list_element *prefixcmd = lookup_cmd_with_subcommands (list, cmdlist); c->prefix = prefixcmd; @@ -323,7 +322,7 @@ add_alias_cmd (const char *name, cmd_list_element *old, /* NOTE: Both FUNC and all the FUNCTIONs need to be copied. */ c->func = old->func; c->function = old->function; - c->prefixlist = old->prefixlist; + c->subcommands = old->subcommands; c->allow_unknown = old->allow_unknown; c->abbrev_flag = abbrev_flag; c->cmd_pointer = old; @@ -358,7 +357,7 @@ add_alias_cmd (const char *name, const char *oldname, static void update_prefix_field_of_prefixed_commands (struct cmd_list_element *c) { - for (cmd_list_element *p = *c->prefixlist; p != NULL; p = p->next) + for (cmd_list_element *p = *c->subcommands; p != NULL; p = p->next) { p->prefix = c; @@ -371,9 +370,9 @@ update_prefix_field_of_prefixed_commands (struct cmd_list_element *c) In such a case, when 'auto-load' was created by do_add_cmd, the 'libthread-db' prefix field could not be updated, as the 'auto-load' command was not yet reachable by - lookup_cmd_for_prefixlist (list, cmdlist) + lookup_cmd_for_subcommands (list, cmdlist) that searches from the top level 'cmdlist'. */ - if (p->prefixlist != nullptr) + if (p->subcommands != nullptr) update_prefix_field_of_prefixed_commands (p); } } @@ -381,18 +380,18 @@ update_prefix_field_of_prefixed_commands (struct cmd_list_element *c) /* Like add_cmd but adds an element for a command prefix: a name that should be followed by a subcommand to be looked up in another - command list. PREFIXLIST should be the address of the variable + command list. SUBCOMMANDS should be the address of the variable containing that list. */ 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 *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list) { struct cmd_list_element *c = add_cmd (name, theclass, fun, doc, list); - c->prefixlist = prefixlist; + c->subcommands = subcommands; c->allow_unknown = allow_unknown; /* Now that prefix command C is defined, we need to set the prefix field @@ -412,7 +411,7 @@ 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 ().c_str (), + help_list (*c->subcommands, c->prefixname ().c_str (), all_commands, gdb_stdout); } @@ -420,11 +419,11 @@ 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 *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list) { struct cmd_list_element *cmd = add_prefix_cmd (name, theclass, nullptr, - doc, prefixlist, + doc, subcommands, allow_unknown, list); set_cmd_sfunc (cmd, do_prefix_cmd); return cmd; @@ -436,18 +435,18 @@ add_basic_prefix_cmd (const char *name, enum command_class theclass, static void do_show_prefix_cmd (const char *args, int from_tty, struct cmd_list_element *c) { - cmd_show_list (*c->prefixlist, from_tty); + cmd_show_list (*c->subcommands, from_tty); } /* See command.h. */ struct cmd_list_element * add_show_prefix_cmd (const char *name, enum command_class theclass, - const char *doc, struct cmd_list_element **prefixlist, + const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list) { struct cmd_list_element *cmd = add_prefix_cmd (name, theclass, nullptr, - doc, prefixlist, + doc, subcommands, allow_unknown, list); set_cmd_sfunc (cmd, do_show_prefix_cmd); return cmd; @@ -460,12 +459,12 @@ 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 *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list, int *suppress_notification) { struct cmd_list_element *element - = add_prefix_cmd (name, theclass, fun, doc, prefixlist, + = add_prefix_cmd (name, theclass, fun, doc, subcommands, allow_unknown, list); element->suppress_notification = suppress_notification; return element; @@ -476,12 +475,12 @@ add_prefix_cmd_suppress_notification 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, + struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list) { struct cmd_list_element *c = add_cmd (name, theclass, fun, doc, list); - c->prefixlist = prefixlist; + c->subcommands = subcommands; c->allow_unknown = allow_unknown; c->abbrev_flag = 1; return c; @@ -1188,11 +1187,11 @@ apropos_cmd (struct ui_file *stream, print_doc_of_command (c, prefix, verbose, regex, stream); } /* Check if this command has subcommands. */ - if (c->prefixlist != NULL) + if (c->subcommands != NULL) { /* Recursively call ourselves on the subcommand list, passing the right prefix in. */ - apropos_cmd (stream, *c->prefixlist, verbose, regex, + apropos_cmd (stream, *c->subcommands, verbose, regex, c->prefixname ().c_str ()); } } @@ -1235,7 +1234,7 @@ help_cmd (const char *command, struct ui_file *stream) lookup_cmd_composition (orig_command, &alias, &prefix_cmd, &c_cmd); /* There are three cases here. - If c->prefixlist is nonzero, we have a prefix command. + If c->subcommands is nonzero, we have a prefix command. Print its documentation, then list its subcommands. If c->func is non NULL, we really have a command. Print its @@ -1253,13 +1252,13 @@ help_cmd (const char *command, struct ui_file *stream) fputs_filtered (c->doc, stream); fputs_filtered ("\n", stream); - if (c->prefixlist == 0 && c->func != NULL) + if (c->subcommands == 0 && c->func != NULL) return; fprintf_filtered (stream, "\n"); /* If this is a prefix command, print it's subcommands. */ - if (c->prefixlist) - help_list (*c->prefixlist, c->prefixname ().c_str (), + if (c->subcommands) + help_list (*c->subcommands, c->prefixname ().c_str (), all_commands, stream); /* If this is a class name, print all of the commands in the class. */ @@ -1450,12 +1449,12 @@ print_help_for_command (struct cmd_list_element *c, fput_aliases_definition_styled (c, stream); if (recurse - && c->prefixlist != 0 + && c->subcommands != 0 && c->abbrev_flag == 0) /* Subcommands of a prefix command typically have 'all_commands' as class. If we pass CLASS to recursive invocation, most often we won't see anything. */ - help_cmd_list (*c->prefixlist, all_commands, true, stream); + help_cmd_list (*c->subcommands, all_commands, true, stream); } /* @@ -1520,10 +1519,10 @@ help_cmd_list (struct cmd_list_element *list, enum command_class theclass, if (recurse && (theclass == class_user || theclass == class_alias) - && c->prefixlist != NULL) + && c->subcommands != NULL) { /* User-defined commands or aliases may be subcommands. */ - help_cmd_list (*c->prefixlist, theclass, recurse, stream); + help_cmd_list (*c->subcommands, theclass, recurse, stream); continue; } @@ -1698,9 +1697,9 @@ lookup_cmd_1 (const char **text, struct cmd_list_element *clist, } /* If we found a prefix command, keep looking. */ - if (found->prefixlist) + if (found->subcommands) { - c = lookup_cmd_1 (text, *found->prefixlist, result_list, default_args, + c = lookup_cmd_1 (text, *found->subcommands, result_list, default_args, ignore_help_classes, lookup_for_completion_p); if (!c) { @@ -1718,7 +1717,7 @@ lookup_cmd_1 (const char **text, struct cmd_list_element *clist, we've found (if an inferior hasn't already set it). */ if (result_list != nullptr) if (!*result_list) - /* This used to say *result_list = *found->prefixlist. + /* This used to say *result_list = *found->subcommands. If that was correct, need to modify the documentation at the top of this function to clarify what is supposed to be going on. */ @@ -1810,14 +1809,14 @@ lookup_cmd (const char **line, struct cmd_list_element *list, } else if (c == CMD_LIST_AMBIGUOUS) { - /* Ambigous. Local values should be off prefixlist or called + /* Ambigous. Local values should be off subcommands or called values. */ int local_allow_unknown = (last_list ? last_list->allow_unknown : allow_unknown); std::string local_cmdtype = last_list ? last_list->prefixname () : cmdtype; struct cmd_list_element *local_list = - (last_list ? *(last_list->prefixlist) : list); + (last_list ? *(last_list->subcommands) : list); if (local_allow_unknown < 0) { @@ -1869,7 +1868,7 @@ lookup_cmd (const char **line, struct cmd_list_element *list, while (**line == ' ' || **line == '\t') (*line)++; - if (c->prefixlist && **line && !c->allow_unknown) + if (c->subcommands && **line && !c->allow_unknown) undef_cmd_error (c->prefixname ().c_str (), *line); /* Seems to be what he wants. Return it. */ @@ -2060,9 +2059,9 @@ lookup_cmd_composition_1 (const char *text, text += len; text = skip_spaces (text); - if ((*cmd)->prefixlist != nullptr && *text != '\0') + if ((*cmd)->subcommands != nullptr && *text != '\0') { - cur_list = *(*cmd)->prefixlist; + cur_list = *(*cmd)->subcommands; *prefix_cmd = *cmd; } else @@ -2127,7 +2126,7 @@ complete_on_cmdlist (struct cmd_list_element *list, if (!strncmp (ptr->name, text, textlen) && !ptr->abbrev_flag && (!ignore_help_classes || ptr->func - || ptr->prefixlist)) + || ptr->subcommands)) { if (pass == 0) { diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h index e6d6f32cbfa..e2428bdddf7 100644 --- a/gdb/cli/cli-decode.h +++ b/gdb/cli/cli-decode.h @@ -187,7 +187,7 @@ struct cmd_list_element /* Nonzero identifies a prefix command. For them, the address of the variable containing the list of subcommands. */ - struct cmd_list_element **prefixlist = nullptr; + struct cmd_list_element **subcommands = nullptr; /* The prefix command of this command. */ struct cmd_list_element *prefix = nullptr; diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index eb8853a5e64..5ddfab9674a 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -1350,10 +1350,10 @@ validate_comname (const char **comname) const char *tem = prefix.c_str (); c = lookup_cmd (&tem, cmdlist, "", NULL, 0, 1); - if (c->prefixlist == NULL) + if (c->subcommands == NULL) error (_("\"%s\" is not a prefix command."), prefix.c_str ()); - list = c->prefixlist; + list = c->subcommands; *comname = last_word; } @@ -1414,7 +1414,7 @@ do_define_command (const char *comname, int from_tty, /* if C is a prefix command that was previously defined, tell the user its subcommands will be kept, and ask if ok to redefine the command. */ - if (c->prefixlist != nullptr) + if (c->subcommands != nullptr) q = (c->user_commands.get () == nullptr || query (_("Keeping subcommands of prefix command \"%s\".\n" "Redefine command \"%s\"? "), c->name, c->name)); @@ -1470,8 +1470,8 @@ do_define_command (const char *comname, int from_tty, cmds = *commands; { - struct cmd_list_element **c_prefixlist - = c == nullptr ? nullptr : c->prefixlist; + struct cmd_list_element **c_subcommands + = c == nullptr ? nullptr : c->subcommands; newc = add_cmd (comname, class_user, user_defined_command, (c != nullptr && c->theclass == class_user) @@ -1480,9 +1480,9 @@ do_define_command (const char *comname, int from_tty, /* If we define or re-define a command that was previously defined as a prefix, keep the prefix information. */ - if (c_prefixlist != nullptr) + if (c_subcommands != nullptr) { - newc->prefixlist = c_prefixlist; + newc->subcommands = c_subcommands; /* allow_unknown: see explanation in equivalent logic in define_prefix_command (). */ newc->allow_unknown = newc->user_commands.get () != nullptr; @@ -1595,7 +1595,7 @@ define_prefix_command (const char *comname, int from_tty) if (c != nullptr && c->theclass != class_user) error (_("Command \"%s\" is built-in."), comfull); - if (c != nullptr && c->prefixlist != nullptr) + if (c != nullptr && c->subcommands != nullptr) { /* c is already a user defined prefix command. */ return; @@ -1609,10 +1609,10 @@ define_prefix_command (const char *comname, int from_tty) xstrdup ("User-defined."), list); } - /* Allocate the c->prefixlist, which marks the command as a prefix + /* Allocate the c->subcommands, which marks the command as a prefix command. */ - c->prefixlist = new struct cmd_list_element*; - *(c->prefixlist) = nullptr; + c->subcommands = new struct cmd_list_element*; + *(c->subcommands) = nullptr; /* 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' @@ -1665,7 +1665,7 @@ show_user_1 (struct cmd_list_element *c, const char *prefix, const char *name, struct command_line *cmdlines = c->user_commands.get (); fprintf_filtered (stream, "User %scommand \"", - c->prefixlist == NULL ? "" : "prefix "); + c->subcommands == NULL ? "" : "prefix "); fprintf_styled (stream, title_style.style (), "%s%s", prefix, name); fprintf_filtered (stream, "\":\n"); @@ -1676,12 +1676,12 @@ show_user_1 (struct cmd_list_element *c, const char *prefix, const char *name, } } - if (c->prefixlist != NULL) + if (c->subcommands != NULL) { const std::string prefixname = c->prefixname (); - for (c = *c->prefixlist; c != NULL; c = c->next) - if (c->theclass == class_user || c->prefixlist != NULL) + for (c = *c->subcommands; c != NULL; c = c->next) + if (c->theclass == class_user || c->subcommands != NULL) show_user_1 (c, prefixname.c_str (), c->name, gdb_stdout); } diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c index 35482e1c5cc..cb72c6241cb 100644 --- a/gdb/cli/cli-setshow.c +++ b/gdb/cli/cli-setshow.c @@ -550,10 +550,10 @@ do_set_command (const char *arg, int from_tty, struct cmd_list_element *c) p = p->prefix; } - /* Don't trigger any observer notification if prefixlist is not + /* Don't trigger any observer notification if subcommands is not setlist. */ i--; - if (cmds[i]->prefixlist != &setlist) + if (cmds[i]->subcommands != &setlist) { xfree (cmds); xfree (name); @@ -740,7 +740,7 @@ cmd_show_list (struct cmd_list_element *list, int from_tty) /* If we find a prefix, run its list, prefixing our output by its prefix (with "show " skipped). */ - if (list->prefixlist && list->cmd_pointer == nullptr) + if (list->subcommands && list->cmd_pointer == nullptr) { ui_out_emit_tuple optionlist_emitter (uiout, "optionlist"); std::string prefixname = list->prefixname (); @@ -748,7 +748,7 @@ cmd_show_list (struct cmd_list_element *list, int from_tty) if (uiout->is_mi_like_p ()) uiout->field_string ("prefix", new_prefix); - cmd_show_list (*list->prefixlist, from_tty); + cmd_show_list (*list->subcommands, from_tty); } else if (list->theclass != no_set_class && list->cmd_pointer == nullptr) { @@ -758,7 +758,7 @@ cmd_show_list (struct cmd_list_element *list, int from_tty) { /* If we find a prefix, output it (with "show " skipped). */ std::string prefixname = list->prefix->prefixname (); - prefixname = (list->prefix->prefixlist == nullptr ? "" + prefixname = (list->prefix->subcommands == nullptr ? "" : strstr (prefixname.c_str (), "show ") + 5); uiout->text (prefixname.c_str ()); } diff --git a/gdb/command.h b/gdb/command.h index 33feb19166c..fe3c7b482f0 100644 --- a/gdb/command.h +++ b/gdb/command.h @@ -208,7 +208,7 @@ extern struct cmd_list_element *add_show_prefix_cmd 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 *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list, int *suppress_notification); diff --git a/gdb/completer.c b/gdb/completer.c index 80e8c7b743e..6d39435c6ca 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -1428,7 +1428,7 @@ complete_line_internal_1 (completion_tracker &tracker, if (result_list) { if (reason != handle_brkchars) - complete_on_cmdlist (*result_list->prefixlist, tracker, p, + complete_on_cmdlist (*result_list->subcommands, tracker, p, word, ignore_help_classes); } else @@ -1456,12 +1456,12 @@ complete_line_internal_1 (completion_tracker &tracker, { /* The command is followed by whitespace; we need to complete on whatever comes after command. */ - if (c->prefixlist) + if (c->subcommands) { /* It is a prefix command; what comes after it is a subcommand (e.g. "info "). */ if (reason != handle_brkchars) - complete_on_cmdlist (*c->prefixlist, tracker, p, word, + complete_on_cmdlist (*c->subcommands, tracker, p, word, ignore_help_classes); /* Ensure that readline does the right thing @@ -1524,7 +1524,7 @@ complete_line_internal_1 (completion_tracker &tracker, { /* There is non-whitespace beyond the command. */ - if (c->prefixlist && !c->allow_unknown) + if (c->subcommands && !c->allow_unknown) { /* It is an unrecognized subcommand of a prefix command, e.g. "info adsfkdj". */ diff --git a/gdb/guile/scm-cmd.c b/gdb/guile/scm-cmd.c index 1f35d881a2d..fc7dc2b7d0b 100644 --- a/gdb/guile/scm-cmd.c +++ b/gdb/guile/scm-cmd.c @@ -524,10 +524,10 @@ gdbscm_parse_command_name (const char *name, gdbscm_scm_from_c_string (name), msg); } - if (elt->prefixlist) + if (elt->subcommands) { xfree (prefix_text); - *base_list = elt->prefixlist; + *base_list = elt->subcommands; return result; } diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c index 6f7794cdf53..c2c0df5798d 100644 --- a/gdb/python/py-cmd.c +++ b/gdb/python/py-cmd.c @@ -111,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->prefixlist != nullptr) + if (obj->command->subcommands != nullptr) { /* A prefix command does not need an invoke method. */ return; @@ -393,9 +393,9 @@ gdbpy_parse_command_name (const char *name, return NULL; } - if (elt->prefixlist) + if (elt->subcommands) { - *base_list = elt->prefixlist; + *base_list = elt->subcommands; return result; } diff --git a/gdb/top.c b/gdb/top.c index 2eb68fd2bc0..a391e9359de 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -647,7 +647,7 @@ execute_command (const char *p, int from_tty) if (c->theclass == class_user && c->user_commands) execute_user_command (c, arg); else if (c->theclass == class_user - && c->prefixlist && !c->allow_unknown) + && c->subcommands && !c->allow_unknown) /* If this is a user defined prefix that does not allow unknown (in other words, C is a prefix command and not a command that can be followed by its args), report the list of @@ -659,7 +659,7 @@ execute_command (const char *p, int from_tty) printf_unfiltered ("\"%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, + help_list (*c->subcommands, prefixname.c_str (), all_commands, gdb_stdout); } else if (c->type == set_cmd) diff --git a/gdb/unittests/command-def-selftests.c b/gdb/unittests/command-def-selftests.c index 040e22b9390..53e5626f645 100644 --- a/gdb/unittests/command-def-selftests.c +++ b/gdb/unittests/command-def-selftests.c @@ -83,11 +83,11 @@ check_doc (struct cmd_list_element *commandlist, const char *prefix) /* Check if this command has subcommands and is not an abbreviation. We skip checking subcommands of abbreviations in order to avoid duplicates in the output. */ - if (c->prefixlist != NULL && !c->abbrev_flag) + if (c->subcommands != NULL && !c->abbrev_flag) { /* Recursively call ourselves on the subcommand list, passing the right prefix in. */ - check_doc (*c->prefixlist, c->prefixname ().c_str ()); + check_doc (*c->subcommands, c->prefixname ().c_str ()); } } } @@ -155,11 +155,11 @@ traverse_command_structure (struct cmd_list_element **list, { /* If this command has subcommands and is not an alias, traverse the subcommands. */ - if (c->prefixlist != NULL && c->cmd_pointer == nullptr) + if (c->subcommands != NULL && c->cmd_pointer == nullptr) { /* Recursively call ourselves on the subcommand list, passing the right prefix in. */ - traverse_command_structure (c->prefixlist, c->prefixname ().c_str ()); + traverse_command_structure (c->subcommands, c->prefixname ().c_str ()); } if (prefixcmd != c->prefix || (prefixcmd == nullptr && *list != cmdlist)) -- 2.30.2