gdb: rename cfunc to simple_func

After browsing the CLI code for quite a while and trying really hard, I
reached the conclusion that I can't give a meaningful explanation of
what "sfunc" and "cfunc" functions are, in cmd_list_element.  I don't
see a logic at all.  That makes it very difficult to do any kind of
change.  Unless somebody can make sense out of all that, I'd like to try
to retro-fit some logic in the cmd_list_element callback function code
so that we can understand what is going on, do some cleanups and add new
features.

The first change is about "cfunc".  I can't figure out what the "c" in
cfunc means.  It's not const, because there's already "const" in
"cmd_const_cfunc_ftype", and the previous "cmd_cfunc_ftype" had nothing
const..  It's not "cmd" or "command", because there's already "cmd" in
"cmd_const_cfunc_ftype".

The "main" command callback, cmd_list_element::func, has three
parameters, whereas cfunc has two.  It is missing the cmd_list_element
parameter.  So the only reason I see for cfunc to exist is to be a shim
between the three and two parameter versions.  Most commands don't need
to receive the cmd_list_element object, so adding it everywhere would be
long and would just add more unnecessary boilerplate.  So since this is
the "simple" version of the callback, compared to the "full", I suggest
renaming cmd_const_cfunc_ftype into cmd_simple_func_ftype, as well as
everything (like the utility functions) that goes with it.

Change-Id: I4e46cacfd77a66bc1cbf683f6a362072504b7868
This commit is contained in:
Simon Marchi
2021-06-29 21:47:23 -04:00
parent 4e93ea6e67
commit 3a553c80da
5 changed files with 53 additions and 44 deletions

View File

@ -655,7 +655,7 @@ validate_actionline (const char *line, struct breakpoint *b)
if (c == 0)
error (_("`%s' is not a tracepoint action, or is ambiguous."), p);
if (cmd_cfunc_eq (c, collect_pseudocommand))
if (cmd_simple_func_eq (c, collect_pseudocommand))
{
int trace_string = 0;
@ -723,7 +723,7 @@ validate_actionline (const char *line, struct breakpoint *b)
while (p && *p++ == ',');
}
else if (cmd_cfunc_eq (c, teval_pseudocommand))
else if (cmd_simple_func_eq (c, teval_pseudocommand))
{
do
{ /* Repeat over a comma-separated list. */
@ -750,7 +750,7 @@ validate_actionline (const char *line, struct breakpoint *b)
while (p && *p++ == ',');
}
else if (cmd_cfunc_eq (c, while_stepping_pseudocommand))
else if (cmd_simple_func_eq (c, while_stepping_pseudocommand))
{
char *endp;
@ -761,7 +761,7 @@ validate_actionline (const char *line, struct breakpoint *b)
p = endp;
}
else if (cmd_cfunc_eq (c, end_actions_pseudocommand))
else if (cmd_simple_func_eq (c, end_actions_pseudocommand))
;
else
@ -1308,7 +1308,7 @@ encode_actions_1 (struct command_line *action,
if (cmd == 0)
error (_("Bad action list item: %s"), action_exp);
if (cmd_cfunc_eq (cmd, collect_pseudocommand))
if (cmd_simple_func_eq (cmd, collect_pseudocommand))
{
int trace_string = 0;
@ -1464,7 +1464,7 @@ encode_actions_1 (struct command_line *action,
}
while (action_exp && *action_exp++ == ',');
} /* if */
else if (cmd_cfunc_eq (cmd, teval_pseudocommand))
else if (cmd_simple_func_eq (cmd, teval_pseudocommand))
{
do
{ /* Repeat over a comma-separated list. */
@ -1488,7 +1488,7 @@ encode_actions_1 (struct command_line *action,
}
while (action_exp && *action_exp++ == ',');
} /* if */
else if (cmd_cfunc_eq (cmd, while_stepping_pseudocommand))
else if (cmd_simple_func_eq (cmd, while_stepping_pseudocommand))
{
/* We check against nested while-stepping when setting
breakpoint action, so no way to run into nested
@ -2690,13 +2690,13 @@ trace_dump_actions (struct command_line *action,
if (cmd == 0)
error (_("Bad action list item: %s"), action_exp);
if (cmd_cfunc_eq (cmd, while_stepping_pseudocommand))
if (cmd_simple_func_eq (cmd, while_stepping_pseudocommand))
{
gdb_assert (action->body_list_1 == nullptr);
trace_dump_actions (action->body_list_0.get (),
1, stepping_frame, from_tty);
}
else if (cmd_cfunc_eq (cmd, collect_pseudocommand))
else if (cmd_simple_func_eq (cmd, collect_pseudocommand))
{
/* Display the collected data.
For the trap frame, display only what was collected at