summaryrefslogtreecommitdiff
path: root/gdb/command.h
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-06-29 23:10:32 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-07-23 15:38:54 -0400
commit5538b03c98e77756b1e1d3e3be86f997a78e6d11 (patch)
treea5cfc5baadd65eb9bfed28fff143687c425a2b94 /gdb/command.h
parent3a553c80da88a45f46ded5d2c058fe2545c8fbdd (diff)
downloadbinutils-gdb-5538b03c98e77756b1e1d3e3be86f997a78e6d11.tar.gz
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/command.h')
-rw-r--r--gdb/command.h30
1 files changed, 14 insertions, 16 deletions
diff --git a/gdb/command.h b/gdb/command.h
index 1bda67c937a..baf34401a07 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -221,10 +221,8 @@ extern struct cmd_list_element *add_abbrev_prefix_cmd (const char *,
struct cmd_list_element
**);
-typedef void cmd_const_sfunc_ftype (const char *args, int from_tty,
- struct cmd_list_element *c);
-extern void set_cmd_sfunc (struct cmd_list_element *cmd,
- cmd_const_sfunc_ftype *sfunc);
+typedef void cmd_func_ftype (const char *args, int from_tty,
+ cmd_list_element *c);
/* A completion routine. Add possible completions to tracker.
@@ -404,73 +402,73 @@ struct set_show_commands
extern set_show_commands add_setshow_enum_cmd
(const char *name, command_class theclass, const char *const *enumlist,
const char **var, const char *set_doc, const char *show_doc,
- const char *help_doc, cmd_const_sfunc_ftype *set_func,
+ const char *help_doc, cmd_func_ftype *set_func,
show_value_ftype *show_func, cmd_list_element **set_list,
cmd_list_element **show_list);
extern set_show_commands add_setshow_auto_boolean_cmd
(const char *name, command_class theclass, auto_boolean *var,
const char *set_doc, const char *show_doc, const char *help_doc,
- cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func,
+ cmd_func_ftype *set_func, show_value_ftype *show_func,
cmd_list_element **set_list, cmd_list_element **show_list);
extern set_show_commands add_setshow_boolean_cmd
(const char *name, command_class theclass, bool *var, const char *set_doc,
- const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func,
+ const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
show_value_ftype *show_func, cmd_list_element **set_list,
cmd_list_element **show_list);
extern set_show_commands add_setshow_filename_cmd
(const char *name, command_class theclass, char **var, const char *set_doc,
- const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func,
+ const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
show_value_ftype *show_func, cmd_list_element **set_list,
cmd_list_element **show_list);
extern set_show_commands add_setshow_string_cmd
(const char *name, command_class theclass, char **var, const char *set_doc,
- const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func,
+ const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
show_value_ftype *show_func, cmd_list_element **set_list,
cmd_list_element **show_list);
extern set_show_commands add_setshow_string_noescape_cmd
(const char *name, command_class theclass, char **var, const char *set_doc,
- const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func,
+ const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
show_value_ftype *show_func, cmd_list_element **set_list,
cmd_list_element **show_list);
extern set_show_commands add_setshow_optional_filename_cmd
(const char *name, command_class theclass, char **var, const char *set_doc,
- const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func,
+ const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
show_value_ftype *show_func, cmd_list_element **set_list,
cmd_list_element **show_list);
extern set_show_commands add_setshow_integer_cmd
(const char *name, command_class theclass, int *var, const char *set_doc,
- const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func,
+ const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
show_value_ftype *show_func, cmd_list_element **set_list,
cmd_list_element **show_list);
extern set_show_commands add_setshow_uinteger_cmd
(const char *name, command_class theclass, unsigned int *var,
const char *set_doc, const char *show_doc, const char *help_doc,
- cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func,
+ cmd_func_ftype *set_func, show_value_ftype *show_func,
cmd_list_element **set_list, cmd_list_element **show_list);
extern set_show_commands add_setshow_zinteger_cmd
(const char *name, command_class theclass, int *var, const char *set_doc,
- const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func,
+ const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
show_value_ftype *show_func, cmd_list_element **set_list,
cmd_list_element **show_list);
extern set_show_commands add_setshow_zuinteger_cmd
(const char *name, command_class theclass, unsigned int *var,
const char *set_doc, const char *show_doc, const char *help_doc,
- cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func,
+ cmd_func_ftype *set_func, show_value_ftype *show_func,
cmd_list_element **set_list, cmd_list_element **show_list);
extern set_show_commands add_setshow_zuinteger_unlimited_cmd
(const char *name, command_class theclass, int *var, const char *set_doc,
- const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func,
+ const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
show_value_ftype *show_func, cmd_list_element **set_list,
cmd_list_element **show_list);