diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-06-29 21:47:23 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-07-23 15:38:54 -0400 |
commit | 3a553c80da88a45f46ded5d2c058fe2545c8fbdd (patch) | |
tree | c927f52a37c4fa46edc564927c032e8ee39b1357 /gdb/command.h | |
parent | 4e93ea6e67fd7260ef842b9eeb20f071648c056e (diff) | |
download | binutils-3a553c80da88a45f46ded5d2c058fe2545c8fbdd.zip binutils-3a553c80da88a45f46ded5d2c058fe2545c8fbdd.tar.gz binutils-3a553c80da88a45f46ded5d2c058fe2545c8fbdd.tar.bz2 |
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
Diffstat (limited to 'gdb/command.h')
-rw-r--r-- | gdb/command.h | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/gdb/command.h b/gdb/command.h index 711cbdc..1bda67c 100644 --- a/gdb/command.h +++ b/gdb/command.h @@ -128,7 +128,10 @@ var_types; /* This structure records one command'd definition. */ struct cmd_list_element; -typedef void cmd_const_cfunc_ftype (const char *args, int from_tty); +/* The "simple" signature of command callbacks, which doesn't include a + cmd_list_element parameter. */ + +typedef void cmd_simple_func_ftype (const char *args, int from_tty); /* This structure specifies notifications to be suppressed by a cli command interpreter. */ @@ -158,7 +161,7 @@ extern bool valid_cmd_char_p (int c); /* Const-correct variant of the above. */ extern struct cmd_list_element *add_cmd (const char *, enum command_class, - cmd_const_cfunc_ftype *fun, + cmd_simple_func_ftype *fun, const char *, struct cmd_list_element **); @@ -170,7 +173,7 @@ extern struct cmd_list_element *add_cmd (const char *, enum command_class, extern struct cmd_list_element *add_cmd_suppress_notification (const char *name, enum command_class theclass, - cmd_const_cfunc_ftype *fun, const char *doc, + cmd_simple_func_ftype *fun, const char *doc, struct cmd_list_element **list, int *suppress_notification); @@ -181,7 +184,7 @@ extern struct cmd_list_element *add_alias_cmd (const char *, extern struct cmd_list_element *add_prefix_cmd (const char *, enum command_class, - cmd_const_cfunc_ftype *fun, + cmd_simple_func_ftype *fun, const char *, struct cmd_list_element **, int, @@ -203,7 +206,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, + cmd_simple_func_ftype *fun, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list, @@ -211,7 +214,7 @@ extern struct cmd_list_element *add_prefix_cmd_suppress_notification extern struct cmd_list_element *add_abbrev_prefix_cmd (const char *, enum command_class, - cmd_const_cfunc_ftype *fun, + cmd_simple_func_ftype *fun, const char *, struct cmd_list_element **, int, @@ -250,8 +253,8 @@ extern void set_cmd_completer_handle_brkchars (struct cmd_list_element *, /* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs around in cmd objects to test the value of the commands sfunc(). */ -extern int cmd_cfunc_eq (struct cmd_list_element *cmd, - cmd_const_cfunc_ftype *cfun); +extern int cmd_simple_func_eq (struct cmd_list_element *cmd, + cmd_simple_func_ftype *cfun); /* Execute CMD's pre/post hook. Throw an error if the command fails. If already executing this pre/post hook, or there is no pre/post @@ -346,7 +349,7 @@ extern int lookup_cmd_composition (const char *text, struct cmd_list_element **cmd); extern struct cmd_list_element *add_com (const char *, enum command_class, - cmd_const_cfunc_ftype *fun, + cmd_simple_func_ftype *fun, const char *); extern cmd_list_element *add_com_alias (const char *name, @@ -356,11 +359,11 @@ extern cmd_list_element *add_com_alias (const char *name, extern struct cmd_list_element *add_com_suppress_notification (const char *name, enum command_class theclass, - cmd_const_cfunc_ftype *fun, const char *doc, + cmd_simple_func_ftype *fun, const char *doc, int *supress_notification); extern struct cmd_list_element *add_info (const char *, - cmd_const_cfunc_ftype *fun, + cmd_simple_func_ftype *fun, const char *); extern cmd_list_element *add_info_alias (const char *name, |