diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-06-29 23:10:32 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-07-23 15:38:54 -0400 |
commit | 5538b03c98e77756b1e1d3e3be86f997a78e6d11 (patch) | |
tree | a5cfc5baadd65eb9bfed28fff143687c425a2b94 /gdb/target.c | |
parent | 3a553c80da88a45f46ded5d2c058fe2545c8fbdd (diff) | |
download | gdb-5538b03c98e77756b1e1d3e3be86f997a78e6d11.zip gdb-5538b03c98e77756b1e1d3e3be86f997a78e6d11.tar.gz gdb-5538b03c98e77756b1e1d3e3be86f997a78e6d11.tar.bz2 |
gdb: remove cmd_list_element::function::sfunc
I don't understand what the sfunc function type in
cmd_list_element::function is for. Compared to cmd_simple_func_ftype,
it has an extra cmd_list_element parameter, giving the callback access
to the cmd_list_element for the command being invoked. This allows
registering the same callback with many commands, and alter the behavior
using the cmd_list_element's context.
From the comment in cmd_list_element, it sounds like at some point it
was the callback function type for set and show functions, hence the
"s". But nowadays, it's used for many more commands that need to access
the cmd_list_element object (see add_catch_command for example).
I don't really see the point of having sfunc at all, since do_sfunc is
just a trivial shim that changes the order of the arguments. All
commands using sfunc could just as well set cmd_list_element::func to
their callback directly.
Therefore, remove the sfunc field in cmd_list_element and everything
that goes with it. Rename cmd_const_sfunc_ftype to cmd_func_ftype and
use it for cmd_list_element::func, as well as for the add_setshow
commands.
Change-Id: I1eb96326c9b511c293c76996cea0ebc51c70fac0
Diffstat (limited to 'gdb/target.c')
-rw-r--r-- | gdb/target.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gdb/target.c b/gdb/target.c index b0f3e88..fe909c2 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -876,7 +876,7 @@ information on the arguments for a particular protocol, type\n\ &targetlist, 0, &cmdlist); c = add_cmd (t.shortname, no_class, t.doc, &targetlist); c->set_context ((void *) &t); - set_cmd_sfunc (c, open_target); + c->func = open_target; if (completer != NULL) set_cmd_completer (c, completer); } @@ -892,7 +892,7 @@ add_deprecated_target_alias (const target_info &tinfo, const char *alias) /* If we use add_alias_cmd, here, we do not get the deprecated warning, see PR cli/15104. */ c = add_cmd (alias, no_class, tinfo.doc, &targetlist); - set_cmd_sfunc (c, open_target); + c->func = open_target; c->set_context ((void *) &tinfo); alt = xstrprintf ("target %s", tinfo.shortname); deprecate_cmd (c, alt); |