aboutsummaryrefslogtreecommitdiff
path: root/gdb/breakpoint.c
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2013-03-12 17:39:45 +0000
committerKeith Seitz <keiths@redhat.com>2013-03-12 17:39:45 +0000
commitbbc13ae3db19a3276ba029c838682f81d10f859a (patch)
tree6f945cef75dd5228c35ff9a554d1d99b28f18d31 /gdb/breakpoint.c
parentf3cec7e61fc4cf16cf150f9e967e6fc9dbbd7207 (diff)
downloadgdb-bbc13ae3db19a3276ba029c838682f81d10f859a.zip
gdb-bbc13ae3db19a3276ba029c838682f81d10f859a.tar.gz
gdb-bbc13ae3db19a3276ba029c838682f81d10f859a.tar.bz2
* ada-lang.c (ada_read_renaming_var_value): Pass const
pointer to expression string to parse_exp_1. (create_excep_cond_exprs): Likewise. * ax-gdb.c (agent_eval_command_one): Likewise. (maint_agent_printf_command): Likewise. Constify much of the string handling/parsing. * breakpoint.c (set_breakpoint_condition): Pass const pointer to expression string to parse_exp_1. (update_watchpoint): Likewise. (parse_cmd_to_aexpr): Constify string handling. Pass const pointer to parse_exp_1. (init_breakpoint_sal): Pass const pointer to parse_exp_1. (find_condition_and_thread): Likewise. Make TOK const. (watch_command_1): Make "arg" const. Constify string handling. Copy the expression string instead of changing the input string. (update_breakpoint_location): Pass const pointer to parse_exp_1. * eval.c (parse_and_eval_address): Make "exp" const. (parse_to_comma_and_eval): Make "expp" const. (parse_and_eval): Make "exp" const. * expression.h (parse_expression): Make argument const. (parse_exp_1): Make first argument const. * findcmd.c (parse_find_args): Treat "args" as const. * linespec.c (parse_linespec): Pass const pointer to linespec_expression_to_pc. (linespec_expression_to_pc): Make "exp_ptr" const. * parse.c (parse_exp_1): Make "stringptr" const. Make a copy of the expression to pass to parse_exp_in_context until this whole interface can be constified. (parse_expression): Make "string" const. * printcmd.c (ui_printf): Treat "arg" as const. Handle const strings. * tracepoint.c (validate_actionline): Pass const pointer to all calls to parse_exp_1. (encode_actions_1): Likewise. * value.h (parse_to_comma_and_eval): Make argument const. (parse_and_eval_address): Likewise. (parse_and_eval): Likewise. * varobj.c (varobj_create): Pass const pointer to parse_exp_1. (varobj_set_value): Likewise. * cli/cli-cmds.c (disassemble_command): Treat "arg" as const and constify string handling. Pass const pointers to parse_and_eval_address and parse_to_comman_and_eval. * cli/cli-utils.c (skip_to_space): Rename to ... (skip_to_space_const): ... this. Handle const strings. * cli/cli-utils.h (skip_to_space): Turn into macro which invokes skip_to_space_const. (skip_to_space_const): Declare. * common/format.c (parse_format_string): Make "arg" const. Handle const strings. * common/format.h (parse_format_string): Make "arg" const. * gdbserver/ax.c (ax_printf): Make "format" const. * python/python.c (gdbpy_parse_and_eval): Do not make a copy of the expression string.
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;