aboutsummaryrefslogtreecommitdiff
path: root/gdb/breakpoint.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/breakpoint.c')
-rw-r--r--gdb/breakpoint.c78
1 files changed, 45 insertions, 33 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index d6f8bc5..e5ee4d0 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -950,7 +950,7 @@ set_breakpoint_condition (struct breakpoint *b, char *exp,
}
else
{
- char *arg = exp;
+ const char *arg = exp;
/* I don't know if it matters whether this is the string the user
typed in or the decompiled expression. */
@@ -1759,7 +1759,7 @@ update_watchpoint (struct watchpoint *b, int reparse)
if (within_current_scope && reparse)
{
- char *s;
+ const char *s;
if (b->exp)
{
@@ -2186,8 +2186,8 @@ parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd)
struct agent_expr *aexpr = NULL;
struct cleanup *old_chain = NULL;
volatile struct gdb_exception ex;
- char *cmdrest;
- char *format_start, *format_end;
+ const char *cmdrest;
+ const char *format_start, *format_end;
struct format_piece *fpieces;
int nargs;
struct gdbarch *gdbarch = get_current_arch ();
@@ -2199,7 +2199,7 @@ parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd)
if (*cmdrest == ',')
++cmdrest;
- cmdrest = skip_spaces (cmdrest);
+ cmdrest = skip_spaces_const (cmdrest);
if (*cmdrest++ != '"')
error (_("No format string following the location"));
@@ -2215,14 +2215,14 @@ parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd)
if (*cmdrest++ != '"')
error (_("Bad format string, non-terminated '\"'."));
- cmdrest = skip_spaces (cmdrest);
+ cmdrest = skip_spaces_const (cmdrest);
if (!(*cmdrest == ',' || *cmdrest == '\0'))
error (_("Invalid argument syntax"));
if (*cmdrest == ',')
cmdrest++;
- cmdrest = skip_spaces (cmdrest);
+ cmdrest = skip_spaces_const (cmdrest);
/* For each argument, make an expression. */
@@ -2232,7 +2232,7 @@ parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd)
nargs = 0;
while (*cmdrest != '\0')
{
- char *cmd1;
+ const char *cmd1;
cmd1 = cmdrest;
expr = parse_exp_1 (&cmd1, scope, block_for_pc (scope), 1);
@@ -9103,7 +9103,8 @@ init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch,
if (b->cond_string)
{
- char *arg = b->cond_string;
+ const char *arg = b->cond_string;
+
loc->cond = parse_exp_1 (&arg, loc->address,
block_for_pc (loc->address), 0);
if (*arg)
@@ -9374,7 +9375,7 @@ invalid_thread_id_error (int id)
If no thread is found, *THREAD is set to -1. */
static void
-find_condition_and_thread (char *tok, CORE_ADDR pc,
+find_condition_and_thread (const char *tok, CORE_ADDR pc,
char **cond_string, int *thread, int *task,
char **rest)
{
@@ -9385,12 +9386,12 @@ find_condition_and_thread (char *tok, CORE_ADDR pc,
while (tok && *tok)
{
- char *end_tok;
+ const char *end_tok;
int toklen;
- char *cond_start = NULL;
- char *cond_end = NULL;
+ const char *cond_start = NULL;
+ const char *cond_end = NULL;
- tok = skip_spaces (tok);
+ tok = skip_spaces_const (tok);
if ((*tok == '"' || *tok == ',') && rest)
{
@@ -9398,7 +9399,7 @@ find_condition_and_thread (char *tok, CORE_ADDR pc,
return;
}
- end_tok = skip_to_space (tok);
+ end_tok = skip_to_space_const (tok);
toklen = end_tok - tok;
@@ -9417,24 +9418,24 @@ find_condition_and_thread (char *tok, CORE_ADDR pc,
char *tmptok;
tok = end_tok + 1;
- tmptok = tok;
- *thread = strtol (tok, &tok, 0);
+ *thread = strtol (tok, &tmptok, 0);
if (tok == tmptok)
error (_("Junk after thread keyword."));
if (!valid_thread_id (*thread))
invalid_thread_id_error (*thread);
+ tok = tmptok;
}
else if (toklen >= 1 && strncmp (tok, "task", toklen) == 0)
{
char *tmptok;
tok = end_tok + 1;
- tmptok = tok;
- *task = strtol (tok, &tok, 0);
+ *task = strtol (tok, &tmptok, 0);
if (tok == tmptok)
error (_("Junk after task keyword."));
if (!valid_task_id (*task))
error (_("Unknown task %d."), *task);
+ tok = tmptok;
}
else if (rest)
{
@@ -10836,7 +10837,7 @@ is_masked_watchpoint (const struct breakpoint *b)
hw_read: watch read,
hw_access: watch access (read or write) */
static void
-watch_command_1 (char *arg, int accessflag, int from_tty,
+watch_command_1 (const char *arg, int accessflag, int from_tty,
int just_location, int internal)
{
volatile struct gdb_exception e;
@@ -10845,12 +10846,12 @@ watch_command_1 (char *arg, int accessflag, int from_tty,
const struct block *exp_valid_block = NULL, *cond_exp_valid_block = NULL;
struct value *val, *mark, *result;
struct frame_info *frame;
- char *exp_start = NULL;
- char *exp_end = NULL;
- char *tok, *end_tok;
+ const char *exp_start = NULL;
+ const char *exp_end = NULL;
+ const char *tok, *end_tok;
int toklen = -1;
- char *cond_start = NULL;
- char *cond_end = NULL;
+ const char *cond_start = NULL;
+ const char *cond_end = NULL;
enum bptype bp_type;
int thread = -1;
int pc = 0;
@@ -10859,15 +10860,19 @@ watch_command_1 (char *arg, int accessflag, int from_tty,
int use_mask = 0;
CORE_ADDR mask = 0;
struct watchpoint *w;
+ char *expression;
+ struct cleanup *back_to;
/* Make sure that we actually have parameters to parse. */
if (arg != NULL && arg[0] != '\0')
{
- char *value_start;
+ const char *value_start;
+
+ exp_end = arg + strlen (arg);
/* Look for "parameter value" pairs at the end
of the arguments string. */
- for (tok = arg + strlen (arg) - 1; tok > arg; tok--)
+ for (tok = exp_end - 1; tok > arg; tok--)
{
/* Skip whitespace at the end of the argument list. */
while (tok > arg && (*tok == ' ' || *tok == '\t'))
@@ -10937,13 +10942,19 @@ watch_command_1 (char *arg, int accessflag, int from_tty,
/* Truncate the string and get rid of the "parameter value" pair before
the arguments string is parsed by the parse_exp_1 function. */
- *tok = '\0';
+ exp_end = tok;
}
}
+ else
+ exp_end = arg;
- /* Parse the rest of the arguments. */
+ /* Parse the rest of the arguments. From here on out, everything
+ is in terms of a newly allocated string instead of the original
+ ARG. */
innermost_block = NULL;
- exp_start = arg;
+ expression = savestring (arg, exp_end - arg);
+ back_to = make_cleanup (xfree, expression);
+ exp_start = arg = expression;
exp = parse_exp_1 (&arg, 0, 0, 0);
exp_end = arg;
/* Remove trailing whitespace from the expression before saving it.
@@ -10989,8 +11000,8 @@ watch_command_1 (char *arg, int accessflag, int from_tty,
else if (val != NULL)
release_value (val);
- tok = skip_spaces (arg);
- end_tok = skip_to_space (tok);
+ tok = skip_spaces_const (arg);
+ end_tok = skip_to_space_const (tok);
toklen = end_tok - tok;
if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
@@ -11142,6 +11153,7 @@ watch_command_1 (char *arg, int accessflag, int from_tty,
}
install_breakpoint (internal, b, 1);
+ do_cleanups (back_to);
}
/* Return count of debug registers needed to watch the given expression.
@@ -14036,7 +14048,7 @@ update_breakpoint_locations (struct breakpoint *b,
old symtab. */
if (b->cond_string != NULL)
{
- char *s;
+ const char *s;
volatile struct gdb_exception e;
s = b->cond_string;