From 0450cc4ce8b4775c47e9aaa1c5a34e181b10ae98 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sat, 9 Sep 2017 20:51:33 -0600 Subject: Add add_cmd function overloads This adds two add_cmd overloads: one whose callback takes a const char *, and one that doesn't accept a function at all. The no-function overload was introduced to avoid ambiguity when NULL was passed as the function. Long term the goal is for all commands to take const arguments, and for the non-const variants to be removed entirely. gdb/ChangeLog 2017-09-27 Tom Tromey * cli/cli-decode.c (add_cmd, set_cmd_cfunc): New function overloads. (do_add_cmd): Rename from add_cmd. Don't call set_cmd_cfunc. (do_const_cfunc): New function. (cmd_cfunc_eq): New overload. (cli_user_command_p): Check do_const_cfunc. * cli/cli-decode.h (struct cmd_list_element) : New field const_cfunc. * command.h (add_cmd): Add const overload and no-function overload. (set_cmd_cfunc): Add const overload. (cmd_const_cfunc_ftype): Declare. (cmd_cfunc_eq): Add const overload. * breakpoint.c, cli-cmds.c, cli-dump.c, guile/scm-cmd.c, python/py-cmd.c, target.c, tracepoint.c: Use no-function add_cmd overload. --- gdb/breakpoint.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gdb/breakpoint.c') diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 8585f5e..5549fe7 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -15414,13 +15414,13 @@ add_catch_command (const char *name, const char *docstring, { struct cmd_list_element *command; - command = add_cmd (name, class_breakpoint, NULL, docstring, + command = add_cmd (name, class_breakpoint, docstring, &catch_cmdlist); set_cmd_sfunc (command, sfunc); set_cmd_context (command, user_data_catch); set_cmd_completer (command, completer); - command = add_cmd (name, class_breakpoint, NULL, docstring, + command = add_cmd (name, class_breakpoint, docstring, &tcatch_cmdlist); set_cmd_sfunc (command, sfunc); set_cmd_context (command, user_data_tcatch); -- cgit v1.1