+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.
+
2017-04-05 Pedro Alves <palves@redhat.com>
* event-top.c (command_line_handler): Add cast to execute_command
}
static void
-handle_gnu_v3_exceptions (int tempflag, char *except_rx, char *cond_string,
+handle_gnu_v3_exceptions (int tempflag, char *except_rx,
+ const char *cond_string,
enum exception_event_kind ex_event, int from_tty)
{
regex_t *pattern = NULL;
the end of the string. */
static char *
-extract_exception_regexp (char **string)
+extract_exception_regexp (const char **string)
{
- char *start;
- char *last, *last_space;
+ const char *start;
+ const char *last, *last_space;
- start = skip_spaces (*string);
+ start = skip_spaces_const (*string);
last = start;
last_space = start;
while (*last != '\0')
{
- char *if_token = last;
+ const char *if_token = last;
/* Check for the "if". */
if (check_for_argument (&if_token, "if", 2))
/* No "if" token here. Skip to the next word start. */
last_space = skip_to_space (last);
- last = skip_spaces (last_space);
+ last = skip_spaces_const (last_space);
}
*string = last;
commands. */
static void
-catch_exception_command_1 (enum exception_event_kind ex_event, char *arg,
+catch_exception_command_1 (enum exception_event_kind ex_event,
+ char *arg_entry,
int tempflag, int from_tty)
{
char *except_rx;
- char *cond_string = NULL;
+ const char *cond_string = NULL;
struct cleanup *cleanup;
+ const char *arg = arg_entry;
if (!arg)
arg = "";
- arg = skip_spaces (arg);
+ arg = skip_spaces_const (arg);
except_rx = extract_exception_regexp (&arg);
cleanup = make_cleanup (xfree, except_rx);
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;
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 ();
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;
/* 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
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;
if (!arg)
arg = "";
- arg = skip_spaces (arg);
+ arg = skip_spaces_const (arg);
/* The allowed syntax is:
catch [v]fork
}
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
extern void init_catchpoint (struct breakpoint *b,
struct gdbarch *gdbarch, int tempflag,
- char *cond_string,
+ const char *cond_string,
const struct breakpoint_ops *ops);
/* Add breakpoint B on the breakpoint list, and notify the user, the
extern void breakpoint_free_objfile (struct objfile *objfile);
-extern char *ep_parse_optional_if_clause (char **arg);
+extern const char *ep_parse_optional_if_clause (const char **arg);
/* Print the "Thread ID hit" part of "Thread ID hit Breakpoint N" to
UIOUT iff debugging multiple threads. */
/* See documentation in cli-utils.h. */
-char *
-remove_trailing_whitespace (const char *start, char *s)
+const char *
+remove_trailing_whitespace (const char *start, const char *s)
{
while (s > start && isspace (*(s - 1)))
--s;
/* See documentation in cli-utils.h. */
int
-check_for_argument (char **str, char *arg, int arg_len)
+check_for_argument (const char **str, const char *arg, int arg_len)
{
if (strncmp (*str, arg, arg_len) == 0
&& ((*str)[arg_len] == '\0' || isspace ((*str)[arg_len])))
/* Reverse S to the last non-whitespace character without skipping past
START. */
-extern char *remove_trailing_whitespace (const char *start, char *s);
+extern const char *remove_trailing_whitespace (const char *start,
+ const char *s);
+
+/* Same, for non-const S. */
+
+static inline char *
+remove_trailing_whitespace (const char *start, char *s)
+{
+ return (char *) remove_trailing_whitespace (start, (const char *) s);
+}
/* A helper function to extract an argument from *ARG. An argument is
delimited by whitespace. The return value is either NULL if no
string. The argument must also either be at the end of the string,
or be followed by whitespace. Returns 1 if it finds the argument,
0 otherwise. If the argument is found, it updates *STR. */
-extern int check_for_argument (char **str, char *arg, int arg_len);
+extern int check_for_argument (const char **str, const char *arg, int arg_len);
+
+/* Same, for non-const STR. */
+
+static inline int
+check_for_argument (char **str, const char *arg, int arg_len)
+{
+ return check_for_argument (const_cast<const char **> (str),
+ arg, arg_len);
+}
#endif /* CLI_UTILS_H */