diff options
author | Pedro Alves <palves@redhat.com> | 2017-04-05 19:21:36 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2017-04-05 19:21:36 +0100 |
commit | 63160a43508fb50d9013df061b2191de71f67b50 (patch) | |
tree | 8bb51f1a9eb796916af8ebaeb56e71e966ead758 /gdb/breakpoint.c | |
parent | 9b2eba3dcc6b41f17180e1aee29ed133f942c733 (diff) | |
download | gdb-63160a43508fb50d9013df061b2191de71f67b50.zip gdb-63160a43508fb50d9013df061b2191de71f67b50.tar.gz gdb-63160a43508fb50d9013df061b2191de71f67b50.tar.bz2 |
-Wwrite-strings: Some constification in gdb/breakpoint.c
The main motivation here is avoiding having to write a couple casts
like these:
if (!arg)
- arg = "";
+ arg = (char *) "";
in catch_exception_command_1 and catch_exec_command_1.
That requires making ep_parse_optional_if_clause and
check_for_argument take pointers to const strings. I then tried
propagating the resulting constification all the way, but that was
spiraling out of control, so instead I settled for keeping const and
non-const overloads.
gdb/ChangeLog:
2017-04-05 Pedro Alves <palves@redhat.com>
* break-catch-throw.c (handle_gnu_v3_exceptions): Constify
'cond_string' parameter.
(extract_exception_regexp): Constify 'string' parameter.
(catch_exception_command_1): Constify.
* breakpoint.c (init_catchpoint)
(create_fork_vfork_event_catchpoint): Constify 'cond_string'
parameter.
(ep_parse_optional_if_clause, catch_fork_command_1)
(catch_exec_command_1): Constify.
* breakpoint.h (init_catchpoint): Constify 'cond_string'
parameter.
(ep_parse_optional_if_clause): Constify.
* cli/cli-utils.c (remove_trailing_whitespace)
(check_for_argument): Constify.
* cli/cli-utils.h (remove_trailing_whitespace): Constify and add
non-const overload.
(check_for_argument): Likewise.
Diffstat (limited to 'gdb/breakpoint.c')
-rw-r--r-- | gdb/breakpoint.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index f0db3e4..4cd7a00 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8582,7 +8582,7 @@ catch_unload_command_1 (char *arg, int from_tty, void init_catchpoint (struct breakpoint *b, struct gdbarch *gdbarch, int tempflag, - char *cond_string, + const char *cond_string, const struct breakpoint_ops *ops) { struct symtab_and_line sal; @@ -8613,7 +8613,7 @@ install_breakpoint (int internal, struct breakpoint *b, int update_gll) static void create_fork_vfork_event_catchpoint (struct gdbarch *gdbarch, - int tempflag, char *cond_string, + int tempflag, const char *cond_string, const struct breakpoint_ops *ops) { struct fork_catchpoint *c = new fork_catchpoint (); @@ -11779,10 +11779,10 @@ until_break_command (char *arg, int from_tty, int anywhere) it updates arg to point to the first character following the parsed if clause in the arg string. */ -char * -ep_parse_optional_if_clause (char **arg) +const char * +ep_parse_optional_if_clause (const char **arg) { - char *cond_string; + const char *cond_string; if (((*arg)[0] != 'i') || ((*arg)[1] != 'f') || !isspace ((*arg)[2])) return NULL; @@ -11792,7 +11792,7 @@ ep_parse_optional_if_clause (char **arg) /* Skip any extra leading whitespace, and record the start of the condition string. */ - *arg = skip_spaces (*arg); + *arg = skip_spaces_const (*arg); cond_string = *arg; /* Assume that the condition occupies the remainder of the arg @@ -11813,11 +11813,12 @@ typedef enum catch_fork_kind; static void -catch_fork_command_1 (char *arg, int from_tty, +catch_fork_command_1 (char *arg_entry, int from_tty, struct cmd_list_element *command) { + const char *arg = arg_entry; struct gdbarch *gdbarch = get_current_arch (); - char *cond_string = NULL; + const char *cond_string = NULL; catch_fork_kind fork_kind; int tempflag; @@ -11827,7 +11828,7 @@ catch_fork_command_1 (char *arg, int from_tty, if (!arg) arg = ""; - arg = skip_spaces (arg); + arg = skip_spaces_const (arg); /* The allowed syntax is: catch [v]fork @@ -11860,19 +11861,20 @@ catch_fork_command_1 (char *arg, int from_tty, } static void -catch_exec_command_1 (char *arg, int from_tty, +catch_exec_command_1 (char *arg_entry, int from_tty, struct cmd_list_element *command) { + const char *arg = arg_entry; struct exec_catchpoint *c; struct gdbarch *gdbarch = get_current_arch (); int tempflag; - char *cond_string = NULL; + const char *cond_string = NULL; tempflag = get_cmd_context (command) == CATCH_TEMPORARY; if (!arg) arg = ""; - arg = skip_spaces (arg); + arg = skip_spaces_const (arg); /* The allowed syntax is: catch exec |