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/cli/cli-decode.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/cli/cli-decode.h')
-rw-r--r-- | gdb/cli/cli-decode.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h index 241535a..4cbdf7f 100644 --- a/gdb/cli/cli-decode.h +++ b/gdb/cli/cli-decode.h @@ -174,8 +174,12 @@ struct cmd_list_element to one of the below. */ union { - /* If type is not_set_cmd, call it like this: */ - cmd_const_cfunc_ftype *const_cfunc; + /* Most commands don't need the cmd_list_element parameter passed to FUNC. + They therefore register a command of this type, which doesn't have the + cmd_list_element parameter. do_simple_func is installed as FUNC, and + acts as a shim between the two. */ + cmd_simple_func_ftype *simple_func; + /* If type is set_cmd or show_cmd, first set the variables, and then call this: */ cmd_const_sfunc_ftype *sfunc; |