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) <prefixlist>: Rename to... <subcommands>: ... this. * cli/cli-decode.c (lookup_cmd_for_prefixlist): Rename to... (lookup_cmd_with_subcommands): ... this. Change-Id: I150da10d03052c2420aa5b0dee41f422e2a97928
This commit is contained in:
parent
ecd0a6b35d
commit
14b42fc4a0
13 changed files with 94 additions and 87 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2021-05-17 Simon Marchi <simon.marchi@polymtl.ca>
|
||||||
|
|
||||||
|
* Rename "prefixlist" parameters to "subcommands" throughout.
|
||||||
|
* cli/cli-decode.h (cmd_list_element) <prefixlist>: Rename to...
|
||||||
|
<subcommands>: ... this.
|
||||||
|
* cli/cli-decode.c (lookup_cmd_for_prefixlist): Rename to...
|
||||||
|
(lookup_cmd_with_subcommands): ... this.
|
||||||
|
|
||||||
2021-05-17 Simon Marchi <simon.marchi@polymtl.ca>
|
2021-05-17 Simon Marchi <simon.marchi@polymtl.ca>
|
||||||
|
|
||||||
* cli/cli-decode.c (add_alias_cmd): Don't handle old == 0.
|
* cli/cli-decode.c (add_alias_cmd): Don't handle old == 0.
|
||||||
|
|
|
@ -1465,7 +1465,7 @@ info_auto_load_cmd (const char *args, int from_tty)
|
||||||
{
|
{
|
||||||
ui_out_emit_tuple option_emitter (uiout, "option");
|
ui_out_emit_tuple option_emitter (uiout, "option");
|
||||||
|
|
||||||
gdb_assert (!list->prefixlist);
|
gdb_assert (!list->subcommands);
|
||||||
gdb_assert (list->type == not_set_cmd);
|
gdb_assert (list->type == not_set_cmd);
|
||||||
|
|
||||||
uiout->field_string ("name", list->name);
|
uiout->field_string ("name", list->name);
|
||||||
|
|
|
@ -1625,7 +1625,7 @@ show_user (const char *args, int from_tty)
|
||||||
{
|
{
|
||||||
for (c = cmdlist; c; c = c->next)
|
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);
|
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. */
|
/* We've already tried to look up COMMAND. */
|
||||||
gdb_assert (c_command != NULL
|
gdb_assert (c_command != NULL
|
||||||
&& c_command != (struct cmd_list_element *) -1);
|
&& 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);
|
c_alias = lookup_cmd_1 (& alias_prefix, cmdlist, NULL, NULL, 1);
|
||||||
if (c_alias != c_command)
|
if (c_alias != c_command)
|
||||||
error (_("ALIAS and COMMAND prefixes do not match."));
|
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]),
|
alias_cmd = add_alias_cmd (xstrdup (alias_argv[alias_argc - 1]),
|
||||||
command_argv[command_argc - 1],
|
command_argv[command_argc - 1],
|
||||||
class_alias, a_opts.abbrev_flag,
|
class_alias, a_opts.abbrev_flag,
|
||||||
c_command->prefixlist);
|
c_command->subcommands);
|
||||||
}
|
}
|
||||||
|
|
||||||
gdb_assert (alias_cmd != nullptr);
|
gdb_assert (alias_cmd != nullptr);
|
||||||
|
|
|
@ -56,12 +56,12 @@ static int lookup_cmd_composition_1 (const char *text,
|
||||||
struct cmd_list_element **cmd,
|
struct cmd_list_element **cmd,
|
||||||
struct cmd_list_element *cur_list);
|
struct cmd_list_element *cur_list);
|
||||||
|
|
||||||
/* Look up a command whose 'prefixlist' is KEY. Return the command if found,
|
/* Look up a command whose 'subcommands' field is SUBCOMMANDS. Return the
|
||||||
otherwise return NULL. */
|
command if found, otherwise return NULL. */
|
||||||
|
|
||||||
static struct cmd_list_element *
|
static struct cmd_list_element *
|
||||||
lookup_cmd_for_prefixlist (struct cmd_list_element **key,
|
lookup_cmd_with_subcommands (cmd_list_element **subcommands,
|
||||||
struct cmd_list_element *list)
|
cmd_list_element *list)
|
||||||
{
|
{
|
||||||
struct cmd_list_element *p = NULL;
|
struct cmd_list_element *p = NULL;
|
||||||
|
|
||||||
|
@ -69,16 +69,16 @@ lookup_cmd_for_prefixlist (struct cmd_list_element **key,
|
||||||
{
|
{
|
||||||
struct cmd_list_element *q;
|
struct cmd_list_element *q;
|
||||||
|
|
||||||
if (p->prefixlist == NULL)
|
if (p->subcommands == NULL)
|
||||||
continue;
|
continue;
|
||||||
else if (p->prefixlist == key)
|
else if (p->subcommands == subcommands)
|
||||||
{
|
{
|
||||||
/* If we found an alias, we must return the aliased
|
/* If we found an alias, we must return the aliased
|
||||||
command. */
|
command. */
|
||||||
return p->cmd_pointer ? p->cmd_pointer : p;
|
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)
|
if (q != NULL)
|
||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ set_cmd_completer_handle_brkchars (struct cmd_list_element *cmd,
|
||||||
std::string
|
std::string
|
||||||
cmd_list_element::prefixname () const
|
cmd_list_element::prefixname () const
|
||||||
{
|
{
|
||||||
if (this->prefixlist == nullptr)
|
if (this->subcommands == nullptr)
|
||||||
/* Not a prefix command. */
|
/* Not a prefix command. */
|
||||||
return "";
|
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.
|
/* Search the prefix cmd of C, and assigns it to C->prefix.
|
||||||
See also add_prefix_cmd and update_prefix_field_of_prefixed_commands. */
|
See also add_prefix_cmd and update_prefix_field_of_prefixed_commands. */
|
||||||
struct cmd_list_element *prefixcmd = lookup_cmd_for_prefixlist (list,
|
cmd_list_element *prefixcmd = lookup_cmd_with_subcommands (list, cmdlist);
|
||||||
cmdlist);
|
|
||||||
c->prefix = prefixcmd;
|
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. */
|
/* NOTE: Both FUNC and all the FUNCTIONs need to be copied. */
|
||||||
c->func = old->func;
|
c->func = old->func;
|
||||||
c->function = old->function;
|
c->function = old->function;
|
||||||
c->prefixlist = old->prefixlist;
|
c->subcommands = old->subcommands;
|
||||||
c->allow_unknown = old->allow_unknown;
|
c->allow_unknown = old->allow_unknown;
|
||||||
c->abbrev_flag = abbrev_flag;
|
c->abbrev_flag = abbrev_flag;
|
||||||
c->cmd_pointer = old;
|
c->cmd_pointer = old;
|
||||||
|
@ -358,7 +357,7 @@ add_alias_cmd (const char *name, const char *oldname,
|
||||||
static void
|
static void
|
||||||
update_prefix_field_of_prefixed_commands (struct cmd_list_element *c)
|
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;
|
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,
|
In such a case, when 'auto-load' was created by do_add_cmd,
|
||||||
the 'libthread-db' prefix field could not be updated, as the
|
the 'libthread-db' prefix field could not be updated, as the
|
||||||
'auto-load' command was not yet reachable by
|
'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'. */
|
that searches from the top level 'cmdlist'. */
|
||||||
if (p->prefixlist != nullptr)
|
if (p->subcommands != nullptr)
|
||||||
update_prefix_field_of_prefixed_commands (p);
|
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
|
/* 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
|
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. */
|
containing that list. */
|
||||||
|
|
||||||
struct cmd_list_element *
|
struct cmd_list_element *
|
||||||
add_prefix_cmd (const char *name, enum command_class theclass,
|
add_prefix_cmd (const char *name, enum command_class theclass,
|
||||||
cmd_const_cfunc_ftype *fun,
|
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 allow_unknown, struct cmd_list_element **list)
|
||||||
{
|
{
|
||||||
struct cmd_list_element *c = add_cmd (name, theclass, fun, doc, 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->allow_unknown = allow_unknown;
|
||||||
|
|
||||||
/* Now that prefix command C is defined, we need to set the prefix field
|
/* 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)
|
while (c->cmd_pointer != nullptr)
|
||||||
c = c->cmd_pointer;
|
c = c->cmd_pointer;
|
||||||
|
|
||||||
help_list (*c->prefixlist, c->prefixname ().c_str (),
|
help_list (*c->subcommands, c->prefixname ().c_str (),
|
||||||
all_commands, gdb_stdout);
|
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 *
|
struct cmd_list_element *
|
||||||
add_basic_prefix_cmd (const char *name, enum command_class theclass,
|
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)
|
int allow_unknown, struct cmd_list_element **list)
|
||||||
{
|
{
|
||||||
struct cmd_list_element *cmd = add_prefix_cmd (name, theclass, nullptr,
|
struct cmd_list_element *cmd = add_prefix_cmd (name, theclass, nullptr,
|
||||||
doc, prefixlist,
|
doc, subcommands,
|
||||||
allow_unknown, list);
|
allow_unknown, list);
|
||||||
set_cmd_sfunc (cmd, do_prefix_cmd);
|
set_cmd_sfunc (cmd, do_prefix_cmd);
|
||||||
return cmd;
|
return cmd;
|
||||||
|
@ -436,18 +435,18 @@ add_basic_prefix_cmd (const char *name, enum command_class theclass,
|
||||||
static void
|
static void
|
||||||
do_show_prefix_cmd (const char *args, int from_tty, struct cmd_list_element *c)
|
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. */
|
/* See command.h. */
|
||||||
|
|
||||||
struct cmd_list_element *
|
struct cmd_list_element *
|
||||||
add_show_prefix_cmd (const char *name, enum command_class theclass,
|
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)
|
int allow_unknown, struct cmd_list_element **list)
|
||||||
{
|
{
|
||||||
struct cmd_list_element *cmd = add_prefix_cmd (name, theclass, nullptr,
|
struct cmd_list_element *cmd = add_prefix_cmd (name, theclass, nullptr,
|
||||||
doc, prefixlist,
|
doc, subcommands,
|
||||||
allow_unknown, list);
|
allow_unknown, list);
|
||||||
set_cmd_sfunc (cmd, do_show_prefix_cmd);
|
set_cmd_sfunc (cmd, do_show_prefix_cmd);
|
||||||
return cmd;
|
return cmd;
|
||||||
|
@ -460,12 +459,12 @@ struct cmd_list_element *
|
||||||
add_prefix_cmd_suppress_notification
|
add_prefix_cmd_suppress_notification
|
||||||
(const char *name, enum command_class theclass,
|
(const char *name, enum command_class theclass,
|
||||||
cmd_const_cfunc_ftype *fun,
|
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 allow_unknown, struct cmd_list_element **list,
|
||||||
int *suppress_notification)
|
int *suppress_notification)
|
||||||
{
|
{
|
||||||
struct cmd_list_element *element
|
struct cmd_list_element *element
|
||||||
= add_prefix_cmd (name, theclass, fun, doc, prefixlist,
|
= add_prefix_cmd (name, theclass, fun, doc, subcommands,
|
||||||
allow_unknown, list);
|
allow_unknown, list);
|
||||||
element->suppress_notification = suppress_notification;
|
element->suppress_notification = suppress_notification;
|
||||||
return element;
|
return element;
|
||||||
|
@ -476,12 +475,12 @@ add_prefix_cmd_suppress_notification
|
||||||
struct cmd_list_element *
|
struct cmd_list_element *
|
||||||
add_abbrev_prefix_cmd (const char *name, enum command_class theclass,
|
add_abbrev_prefix_cmd (const char *name, enum command_class theclass,
|
||||||
cmd_const_cfunc_ftype *fun, const char *doc,
|
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)
|
int allow_unknown, struct cmd_list_element **list)
|
||||||
{
|
{
|
||||||
struct cmd_list_element *c = add_cmd (name, theclass, fun, doc, 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->allow_unknown = allow_unknown;
|
||||||
c->abbrev_flag = 1;
|
c->abbrev_flag = 1;
|
||||||
return c;
|
return c;
|
||||||
|
@ -1188,11 +1187,11 @@ apropos_cmd (struct ui_file *stream,
|
||||||
print_doc_of_command (c, prefix, verbose, regex, stream);
|
print_doc_of_command (c, prefix, verbose, regex, stream);
|
||||||
}
|
}
|
||||||
/* Check if this command has subcommands. */
|
/* Check if this command has subcommands. */
|
||||||
if (c->prefixlist != NULL)
|
if (c->subcommands != NULL)
|
||||||
{
|
{
|
||||||
/* Recursively call ourselves on the subcommand list,
|
/* Recursively call ourselves on the subcommand list,
|
||||||
passing the right prefix in. */
|
passing the right prefix in. */
|
||||||
apropos_cmd (stream, *c->prefixlist, verbose, regex,
|
apropos_cmd (stream, *c->subcommands, verbose, regex,
|
||||||
c->prefixname ().c_str ());
|
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);
|
lookup_cmd_composition (orig_command, &alias, &prefix_cmd, &c_cmd);
|
||||||
|
|
||||||
/* There are three cases here.
|
/* 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.
|
Print its documentation, then list its subcommands.
|
||||||
|
|
||||||
If c->func is non NULL, we really have a command. Print its
|
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 (c->doc, stream);
|
||||||
fputs_filtered ("\n", stream);
|
fputs_filtered ("\n", stream);
|
||||||
|
|
||||||
if (c->prefixlist == 0 && c->func != NULL)
|
if (c->subcommands == 0 && c->func != NULL)
|
||||||
return;
|
return;
|
||||||
fprintf_filtered (stream, "\n");
|
fprintf_filtered (stream, "\n");
|
||||||
|
|
||||||
/* If this is a prefix command, print it's subcommands. */
|
/* If this is a prefix command, print it's subcommands. */
|
||||||
if (c->prefixlist)
|
if (c->subcommands)
|
||||||
help_list (*c->prefixlist, c->prefixname ().c_str (),
|
help_list (*c->subcommands, c->prefixname ().c_str (),
|
||||||
all_commands, stream);
|
all_commands, stream);
|
||||||
|
|
||||||
/* If this is a class name, print all of the commands in the class. */
|
/* 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);
|
fput_aliases_definition_styled (c, stream);
|
||||||
|
|
||||||
if (recurse
|
if (recurse
|
||||||
&& c->prefixlist != 0
|
&& c->subcommands != 0
|
||||||
&& c->abbrev_flag == 0)
|
&& c->abbrev_flag == 0)
|
||||||
/* Subcommands of a prefix command typically have 'all_commands'
|
/* Subcommands of a prefix command typically have 'all_commands'
|
||||||
as class. If we pass CLASS to recursive invocation,
|
as class. If we pass CLASS to recursive invocation,
|
||||||
most often we won't see anything. */
|
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
|
if (recurse
|
||||||
&& (theclass == class_user || theclass == class_alias)
|
&& (theclass == class_user || theclass == class_alias)
|
||||||
&& c->prefixlist != NULL)
|
&& c->subcommands != NULL)
|
||||||
{
|
{
|
||||||
/* User-defined commands or aliases may be subcommands. */
|
/* 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;
|
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 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);
|
ignore_help_classes, lookup_for_completion_p);
|
||||||
if (!c)
|
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). */
|
we've found (if an inferior hasn't already set it). */
|
||||||
if (result_list != nullptr)
|
if (result_list != nullptr)
|
||||||
if (!*result_list)
|
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
|
If that was correct, need to modify the documentation
|
||||||
at the top of this function to clarify what is
|
at the top of this function to clarify what is
|
||||||
supposed to be going on. */
|
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)
|
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. */
|
values. */
|
||||||
int local_allow_unknown = (last_list ? last_list->allow_unknown :
|
int local_allow_unknown = (last_list ? last_list->allow_unknown :
|
||||||
allow_unknown);
|
allow_unknown);
|
||||||
std::string local_cmdtype
|
std::string local_cmdtype
|
||||||
= last_list ? last_list->prefixname () : cmdtype;
|
= last_list ? last_list->prefixname () : cmdtype;
|
||||||
struct cmd_list_element *local_list =
|
struct cmd_list_element *local_list =
|
||||||
(last_list ? *(last_list->prefixlist) : list);
|
(last_list ? *(last_list->subcommands) : list);
|
||||||
|
|
||||||
if (local_allow_unknown < 0)
|
if (local_allow_unknown < 0)
|
||||||
{
|
{
|
||||||
|
@ -1869,7 +1868,7 @@ lookup_cmd (const char **line, struct cmd_list_element *list,
|
||||||
while (**line == ' ' || **line == '\t')
|
while (**line == ' ' || **line == '\t')
|
||||||
(*line)++;
|
(*line)++;
|
||||||
|
|
||||||
if (c->prefixlist && **line && !c->allow_unknown)
|
if (c->subcommands && **line && !c->allow_unknown)
|
||||||
undef_cmd_error (c->prefixname ().c_str (), *line);
|
undef_cmd_error (c->prefixname ().c_str (), *line);
|
||||||
|
|
||||||
/* Seems to be what he wants. Return it. */
|
/* Seems to be what he wants. Return it. */
|
||||||
|
@ -2060,9 +2059,9 @@ lookup_cmd_composition_1 (const char *text,
|
||||||
text += len;
|
text += len;
|
||||||
text = skip_spaces (text);
|
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;
|
*prefix_cmd = *cmd;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2127,7 +2126,7 @@ complete_on_cmdlist (struct cmd_list_element *list,
|
||||||
if (!strncmp (ptr->name, text, textlen)
|
if (!strncmp (ptr->name, text, textlen)
|
||||||
&& !ptr->abbrev_flag
|
&& !ptr->abbrev_flag
|
||||||
&& (!ignore_help_classes || ptr->func
|
&& (!ignore_help_classes || ptr->func
|
||||||
|| ptr->prefixlist))
|
|| ptr->subcommands))
|
||||||
{
|
{
|
||||||
if (pass == 0)
|
if (pass == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -187,7 +187,7 @@ struct cmd_list_element
|
||||||
|
|
||||||
/* Nonzero identifies a prefix command. For them, the address
|
/* Nonzero identifies a prefix command. For them, the address
|
||||||
of the variable containing the list of subcommands. */
|
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. */
|
/* The prefix command of this command. */
|
||||||
struct cmd_list_element *prefix = nullptr;
|
struct cmd_list_element *prefix = nullptr;
|
||||||
|
|
|
@ -1350,10 +1350,10 @@ validate_comname (const char **comname)
|
||||||
const char *tem = prefix.c_str ();
|
const char *tem = prefix.c_str ();
|
||||||
|
|
||||||
c = lookup_cmd (&tem, cmdlist, "", NULL, 0, 1);
|
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 ());
|
error (_("\"%s\" is not a prefix command."), prefix.c_str ());
|
||||||
|
|
||||||
list = c->prefixlist;
|
list = c->subcommands;
|
||||||
*comname = last_word;
|
*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,
|
/* if C is a prefix command that was previously defined,
|
||||||
tell the user its subcommands will be kept, and ask
|
tell the user its subcommands will be kept, and ask
|
||||||
if ok to redefine the command. */
|
if ok to redefine the command. */
|
||||||
if (c->prefixlist != nullptr)
|
if (c->subcommands != nullptr)
|
||||||
q = (c->user_commands.get () == nullptr
|
q = (c->user_commands.get () == nullptr
|
||||||
|| query (_("Keeping subcommands of prefix command \"%s\".\n"
|
|| query (_("Keeping subcommands of prefix command \"%s\".\n"
|
||||||
"Redefine command \"%s\"? "), c->name, c->name));
|
"Redefine command \"%s\"? "), c->name, c->name));
|
||||||
|
@ -1470,8 +1470,8 @@ do_define_command (const char *comname, int from_tty,
|
||||||
cmds = *commands;
|
cmds = *commands;
|
||||||
|
|
||||||
{
|
{
|
||||||
struct cmd_list_element **c_prefixlist
|
struct cmd_list_element **c_subcommands
|
||||||
= c == nullptr ? nullptr : c->prefixlist;
|
= c == nullptr ? nullptr : c->subcommands;
|
||||||
|
|
||||||
newc = add_cmd (comname, class_user, user_defined_command,
|
newc = add_cmd (comname, class_user, user_defined_command,
|
||||||
(c != nullptr && c->theclass == class_user)
|
(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
|
/* If we define or re-define a command that was previously defined
|
||||||
as a prefix, keep the prefix information. */
|
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
|
/* allow_unknown: see explanation in equivalent logic in
|
||||||
define_prefix_command (). */
|
define_prefix_command (). */
|
||||||
newc->allow_unknown = newc->user_commands.get () != nullptr;
|
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)
|
if (c != nullptr && c->theclass != class_user)
|
||||||
error (_("Command \"%s\" is built-in."), comfull);
|
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. */
|
/* c is already a user defined prefix command. */
|
||||||
return;
|
return;
|
||||||
|
@ -1609,10 +1609,10 @@ define_prefix_command (const char *comname, int from_tty)
|
||||||
xstrdup ("User-defined."), list);
|
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. */
|
command. */
|
||||||
c->prefixlist = new struct cmd_list_element*;
|
c->subcommands = new struct cmd_list_element*;
|
||||||
*(c->prefixlist) = nullptr;
|
*(c->subcommands) = nullptr;
|
||||||
/* If the prefix command C is not a command, then it must be followed
|
/* 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,
|
by known subcommands. Otherwise, if C is also a normal command,
|
||||||
it can be followed by C args that must not cause a 'subcommand'
|
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 ();
|
struct command_line *cmdlines = c->user_commands.get ();
|
||||||
|
|
||||||
fprintf_filtered (stream, "User %scommand \"",
|
fprintf_filtered (stream, "User %scommand \"",
|
||||||
c->prefixlist == NULL ? "" : "prefix ");
|
c->subcommands == NULL ? "" : "prefix ");
|
||||||
fprintf_styled (stream, title_style.style (), "%s%s",
|
fprintf_styled (stream, title_style.style (), "%s%s",
|
||||||
prefix, name);
|
prefix, name);
|
||||||
fprintf_filtered (stream, "\":\n");
|
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 ();
|
const std::string prefixname = c->prefixname ();
|
||||||
|
|
||||||
for (c = *c->prefixlist; c != NULL; c = c->next)
|
for (c = *c->subcommands; c != NULL; c = c->next)
|
||||||
if (c->theclass == class_user || c->prefixlist != NULL)
|
if (c->theclass == class_user || c->subcommands != NULL)
|
||||||
show_user_1 (c, prefixname.c_str (), c->name, gdb_stdout);
|
show_user_1 (c, prefixname.c_str (), c->name, gdb_stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -550,10 +550,10 @@ do_set_command (const char *arg, int from_tty, struct cmd_list_element *c)
|
||||||
p = p->prefix;
|
p = p->prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't trigger any observer notification if prefixlist is not
|
/* Don't trigger any observer notification if subcommands is not
|
||||||
setlist. */
|
setlist. */
|
||||||
i--;
|
i--;
|
||||||
if (cmds[i]->prefixlist != &setlist)
|
if (cmds[i]->subcommands != &setlist)
|
||||||
{
|
{
|
||||||
xfree (cmds);
|
xfree (cmds);
|
||||||
xfree (name);
|
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
|
/* If we find a prefix, run its list, prefixing our output by its
|
||||||
prefix (with "show " skipped). */
|
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");
|
ui_out_emit_tuple optionlist_emitter (uiout, "optionlist");
|
||||||
std::string prefixname = list->prefixname ();
|
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 ())
|
if (uiout->is_mi_like_p ())
|
||||||
uiout->field_string ("prefix", new_prefix);
|
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)
|
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). */
|
/* If we find a prefix, output it (with "show " skipped). */
|
||||||
std::string prefixname = list->prefix->prefixname ();
|
std::string prefixname = list->prefix->prefixname ();
|
||||||
prefixname = (list->prefix->prefixlist == nullptr ? ""
|
prefixname = (list->prefix->subcommands == nullptr ? ""
|
||||||
: strstr (prefixname.c_str (), "show ") + 5);
|
: strstr (prefixname.c_str (), "show ") + 5);
|
||||||
uiout->text (prefixname.c_str ());
|
uiout->text (prefixname.c_str ());
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,7 +208,7 @@ extern struct cmd_list_element *add_show_prefix_cmd
|
||||||
extern struct cmd_list_element *add_prefix_cmd_suppress_notification
|
extern struct cmd_list_element *add_prefix_cmd_suppress_notification
|
||||||
(const char *name, enum command_class theclass,
|
(const char *name, enum command_class theclass,
|
||||||
cmd_const_cfunc_ftype *fun,
|
cmd_const_cfunc_ftype *fun,
|
||||||
const char *doc, struct cmd_list_element **prefixlist,
|
const char *doc, struct cmd_list_element **subcommands,
|
||||||
int allow_unknown,
|
int allow_unknown,
|
||||||
struct cmd_list_element **list,
|
struct cmd_list_element **list,
|
||||||
int *suppress_notification);
|
int *suppress_notification);
|
||||||
|
|
|
@ -1428,7 +1428,7 @@ complete_line_internal_1 (completion_tracker &tracker,
|
||||||
if (result_list)
|
if (result_list)
|
||||||
{
|
{
|
||||||
if (reason != handle_brkchars)
|
if (reason != handle_brkchars)
|
||||||
complete_on_cmdlist (*result_list->prefixlist, tracker, p,
|
complete_on_cmdlist (*result_list->subcommands, tracker, p,
|
||||||
word, ignore_help_classes);
|
word, ignore_help_classes);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1456,12 +1456,12 @@ complete_line_internal_1 (completion_tracker &tracker,
|
||||||
{
|
{
|
||||||
/* The command is followed by whitespace; we need to
|
/* The command is followed by whitespace; we need to
|
||||||
complete on whatever comes after command. */
|
complete on whatever comes after command. */
|
||||||
if (c->prefixlist)
|
if (c->subcommands)
|
||||||
{
|
{
|
||||||
/* It is a prefix command; what comes after it is
|
/* It is a prefix command; what comes after it is
|
||||||
a subcommand (e.g. "info "). */
|
a subcommand (e.g. "info "). */
|
||||||
if (reason != handle_brkchars)
|
if (reason != handle_brkchars)
|
||||||
complete_on_cmdlist (*c->prefixlist, tracker, p, word,
|
complete_on_cmdlist (*c->subcommands, tracker, p, word,
|
||||||
ignore_help_classes);
|
ignore_help_classes);
|
||||||
|
|
||||||
/* Ensure that readline does the right thing
|
/* 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. */
|
/* 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,
|
/* It is an unrecognized subcommand of a prefix command,
|
||||||
e.g. "info adsfkdj". */
|
e.g. "info adsfkdj". */
|
||||||
|
|
|
@ -524,10 +524,10 @@ gdbscm_parse_command_name (const char *name,
|
||||||
gdbscm_scm_from_c_string (name), msg);
|
gdbscm_scm_from_c_string (name), msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elt->prefixlist)
|
if (elt->subcommands)
|
||||||
{
|
{
|
||||||
xfree (prefix_text);
|
xfree (prefix_text);
|
||||||
*base_list = elt->prefixlist;
|
*base_list = elt->subcommands;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ cmdpy_function (struct cmd_list_element *command,
|
||||||
error (_("Invalid invocation of Python command object."));
|
error (_("Invalid invocation of Python command object."));
|
||||||
if (! PyObject_HasAttr ((PyObject *) obj, invoke_cst))
|
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. */
|
/* A prefix command does not need an invoke method. */
|
||||||
return;
|
return;
|
||||||
|
@ -393,9 +393,9 @@ gdbpy_parse_command_name (const char *name,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elt->prefixlist)
|
if (elt->subcommands)
|
||||||
{
|
{
|
||||||
*base_list = elt->prefixlist;
|
*base_list = elt->subcommands;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -647,7 +647,7 @@ execute_command (const char *p, int from_tty)
|
||||||
if (c->theclass == class_user && c->user_commands)
|
if (c->theclass == class_user && c->user_commands)
|
||||||
execute_user_command (c, arg);
|
execute_user_command (c, arg);
|
||||||
else if (c->theclass == class_user
|
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
|
/* If this is a user defined prefix that does not allow unknown
|
||||||
(in other words, C is a prefix command and not a command
|
(in other words, C is a prefix command and not a command
|
||||||
that can be followed by its args), report the list of
|
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
|
printf_unfiltered
|
||||||
("\"%s\" must be followed by the name of a subcommand.\n",
|
("\"%s\" must be followed by the name of a subcommand.\n",
|
||||||
prefixname_no_space.c_str ());
|
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);
|
gdb_stdout);
|
||||||
}
|
}
|
||||||
else if (c->type == set_cmd)
|
else if (c->type == set_cmd)
|
||||||
|
|
|
@ -83,11 +83,11 @@ check_doc (struct cmd_list_element *commandlist, const char *prefix)
|
||||||
/* Check if this command has subcommands and is not an
|
/* Check if this command has subcommands and is not an
|
||||||
abbreviation. We skip checking subcommands of abbreviations
|
abbreviation. We skip checking subcommands of abbreviations
|
||||||
in order to avoid duplicates in the output. */
|
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,
|
/* Recursively call ourselves on the subcommand list,
|
||||||
passing the right prefix in. */
|
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,
|
/* If this command has subcommands and is not an alias,
|
||||||
traverse the subcommands. */
|
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,
|
/* Recursively call ourselves on the subcommand list,
|
||||||
passing the right prefix in. */
|
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
|
if (prefixcmd != c->prefix
|
||||||
|| (prefixcmd == nullptr && *list != cmdlist))
|
|| (prefixcmd == nullptr && *list != cmdlist))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue