Same idea as the previous patches, but for whether a command is a
"command class help" command. I think this one is particularly useful,
because it's not obvious when reading code what "c->func == NULL" means.
Remove the cmd_func_p function, which does kind of the same thing as
cmd_list_element::is_command_class_help (except it doesn't give a clue
about the semantic of a NULL func value).
gdb/ChangeLog:
* cli/cli-decode.h (cmd_list_element) <is_command_class_help>:
New, use it.
* command.h (cmd_func_p): Remove.
* cli/cli-decode.c (cmd_func_p): Remove.
Change-Id: I521a3e1896dc93a5babe1493d18f5eb071e1b3b7
+2021-05-17 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * cli/cli-decode.h (cmd_list_element) <is_command_class_help>:
+ New, use it.
+ * command.h (cmd_func_p): Remove.
+ * cli/cli-decode.c (cmd_func_p): Remove.
+
2021-05-17 Simon Marchi <simon.marchi@polymtl.ca>
* cli/cli-decode.h (cmd_list_element) <is_alias>: New, use it.
2021-05-17 Simon Marchi <simon.marchi@polymtl.ca>
* cli/cli-decode.h (cmd_list_element) <is_alias>: New, use it.
fputs_filtered (c->doc, stream);
fputs_filtered ("\n", stream);
fputs_filtered (c->doc, stream);
fputs_filtered ("\n", stream);
- if (!c->is_prefix () && c->func != NULL)
+ if (!c->is_prefix () && !c->is_command_class_help ())
return;
fprintf_filtered (stream, "\n");
return;
fprintf_filtered (stream, "\n");
all_commands, stream);
/* If this is a class name, print all of the commands in the class. */
all_commands, stream);
/* If this is a class name, print all of the commands in the class. */
+ if (c->is_command_class_help ())
help_list (cmdlist, "", c->theclass, stream);
if (c->hook_pre || c->hook_post)
help_list (cmdlist, "", c->theclass, stream);
if (c->hook_pre || c->hook_post)
/* 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. */
+ if (c->is_command_class_help ())
{
fprintf_filtered (stream, "\nCommand class: %s\n\n", c->name);
help_cmd_list (cmdlist, c->theclass, true, stream);
{
fprintf_filtered (stream, "\nCommand class: %s\n\n", c->name);
help_cmd_list (cmdlist, c->theclass, true, stream);
}
if (theclass == all_commands
}
if (theclass == all_commands
- || (theclass == all_classes && c->func == NULL)
- || (theclass == c->theclass && c->func != NULL))
+ || (theclass == all_classes && c->is_command_class_help ())
+ || (theclass == c->theclass && !c->is_command_class_help ()))
{
/* show C when
- showing all commands
{
/* show C when
- showing all commands
*nfound = 0;
for (c = clist; c; c = c->next)
if (!strncmp (command, c->name, len)
*nfound = 0;
for (c = clist; c; c = c->next)
if (!strncmp (command, c->name, len)
- && (!ignore_help_classes || c->func))
+ && (!ignore_help_classes || !c->is_command_class_help ()))
{
found = c;
(*nfound)++;
{
found = c;
(*nfound)++;
for (ptr = list; ptr; ptr = ptr->next)
if (!strncmp (ptr->name, text, textlen)
&& !ptr->abbrev_flag
for (ptr = list; ptr; ptr = ptr->next)
if (!strncmp (ptr->name, text, textlen)
&& !ptr->abbrev_flag
- && (!ignore_help_classes || ptr->func
+ && (!ignore_help_classes || !ptr->is_command_class_help ()
|| ptr->is_prefix ()))
{
if (pass == 0)
|| ptr->is_prefix ()))
{
if (pass == 0)
tracker.add_completion (make_completion_match_str (name, text, word));
}
tracker.add_completion (make_completion_match_str (name, text, word));
}
-
-/* Check function pointer. */
-int
-cmd_func_p (struct cmd_list_element *cmd)
-{
- return (cmd->func != NULL);
-}
-
-
/* Call the command function. */
void
cmd_func (struct cmd_list_element *cmd, const char *args, int from_tty)
{
/* Call the command function. */
void
cmd_func (struct cmd_list_element *cmd, const char *args, int from_tty)
{
+ if (!cmd->is_command_class_help ())
{
gdb::optional<scoped_restore_tmpl<int>> restore_suppress;
{
gdb::optional<scoped_restore_tmpl<int>> restore_suppress;
bool is_prefix () const
{ return this->subcommands != nullptr; }
bool is_prefix () const
{ return this->subcommands != nullptr; }
+ /* Return true if this command is a "command class help" command. For
+ instance, a "stack" dummy command is registered so that one can do
+ "help stack" and show help for all commands of the "stack" class. */
+ bool is_command_class_help () const
+ { return this->func == nullptr; }
+
/* Points to next command in this list. */
struct cmd_list_element *next = nullptr;
/* Points to next command in this list. */
struct cmd_list_element *next = nullptr;
extern void not_just_help_class_command (const char *, int);
extern void not_just_help_class_command (const char *, int);
-/* Check function pointer. */
-extern int cmd_func_p (struct cmd_list_element *cmd);
-
/* Call the command function. */
extern void cmd_func (struct cmd_list_element *cmd,
const char *args, int from_tty);
/* Call the command function. */
extern void cmd_func (struct cmd_list_element *cmd,
const char *args, int from_tty);
do_set_command (arg, from_tty, c);
else if (c->type == show_cmd)
do_show_command (arg, from_tty, c);
do_set_command (arg, from_tty, c);
else if (c->type == show_cmd)
do_show_command (arg, from_tty, c);
- else if (!cmd_func_p (c))
+ else if (c->is_command_class_help ())
error (_("That is not a command, just a help topic."));
else if (deprecated_call_command_hook)
deprecated_call_command_hook (c, arg, from_tty);
error (_("That is not a command, just a help topic."));
else if (deprecated_call_command_hook)
deprecated_call_command_hook (c, arg, from_tty);