This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] "constify" parse_exp_1
- From: Keith Seitz <keiths at redhat dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: "gdb-patches at sourceware dot org ml" <gdb-patches at sourceware dot org>
- Date: Thu, 07 Mar 2013 17:01:58 -0800
- Subject: Re: [RFA] "constify" parse_exp_1
- References: <51392C56.7040302@redhat.com> <51392F3F.5090102@redhat.com>
On 03/07/2013 04:22 PM, Pedro Alves wrote:
>
I didn't get past the first hunk in the patch. :-)
Gah! That's what happens (sometimes) when you get too used to making
mechanical changes. My apologies!
Your patch seems to make sym_name unused, even. There may be
more instances of this in the patch. /me off to bed. :-)
I *think* that's the only one. The only other places where a
less-than-mechanical change is made is watch_command_1 (which is one
hairy beast), find_condition_and_thread (which is still pretty trivial),
and the tracepoint.c changes (which are almost as much a hairy beast).
So, allow me try again. Thank you! [And sleep well; this will be in your
INBOX in the morning. :-P]
Keith
ChangeLog
2013-03-07 Keith Seitz <keiths@redhat.com>
* ada-lang.c (ada_read_renaming_var_value): Pass const
pointer to expression string to parse_exp_1.
(craete_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): Constify string handling.
(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.
* 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.
* 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.
Index: ada-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/ada-lang.c,v
retrieving revision 1.394
diff -u -p -r1.394 ada-lang.c
--- ada-lang.c 5 Mar 2013 21:15:34 -0000 1.394
+++ ada-lang.c 8 Mar 2013 00:52:43 -0000
@@ -4056,15 +4056,14 @@ static struct value *
ada_read_renaming_var_value (struct symbol *renaming_sym,
struct block *block)
{
- char *sym_name;
+ const char *sym_name;
struct expression *expr;
struct value *value;
struct cleanup *old_chain = NULL;
- sym_name = xstrdup (SYMBOL_LINKAGE_NAME (renaming_sym));
- old_chain = make_cleanup (xfree, sym_name);
+ sym_name = SYMBOL_LINKAGE_NAME (renaming_sym);
expr = parse_exp_1 (&sym_name, 0, block, 0);
- make_cleanup (free_current_contents, &expr);
+ old_chain = make_cleanup (free_current_contents, &expr);
value = evaluate_expression (expr);
do_cleanups (old_chain);
@@ -11385,7 +11384,7 @@ create_excep_cond_exprs (struct ada_catc
if (!bl->shlib_disabled)
{
volatile struct gdb_exception e;
- char *s;
+ const char *s;
s = cond_string;
TRY_CATCH (e, RETURN_MASK_ERROR)
Index: ax-gdb.c
===================================================================
RCS file: /cvs/src/src/gdb/ax-gdb.c,v
retrieving revision 1.109
diff -u -p -r1.109 ax-gdb.c
--- ax-gdb.c 7 Mar 2013 00:48:25 -0000 1.109
+++ ax-gdb.c 8 Mar 2013 00:52:43 -0000
@@ -2608,6 +2608,7 @@ agent_eval_command_one (char *exp, int e
struct cleanup *old_chain = 0;
struct expression *expr;
struct agent_expr *agent;
+ const char *arg;
if (!eval)
{
@@ -2616,14 +2617,15 @@ agent_eval_command_one (char *exp, int e
exp = decode_agent_options (exp);
}
- if (!eval && strcmp (exp, "$_ret") == 0)
+ arg = exp;
+ if (!eval && strcmp (arg, "$_ret") == 0)
{
agent = gen_trace_for_return_address (pc, get_current_arch ());
old_chain = make_cleanup_free_agent_expr (agent);
}
else
{
- expr = parse_exp_1 (&exp, pc, block_for_pc (pc), 0);
+ expr = parse_exp_1 (&arg, pc, block_for_pc (pc), 0);
old_chain = make_cleanup (free_current_contents, &expr);
if (eval)
agent = gen_eval_for_expr (pc, expr);
@@ -2716,8 +2718,8 @@ maint_agent_printf_command (char *exp, i
struct expression *argvec[100];
struct agent_expr *agent;
struct frame_info *fi = get_current_frame (); /* need current scope */
- char *cmdrest;
- char *format_start, *format_end;
+ const char *cmdrest;
+ const char *format_start, *format_end;
struct format_piece *fpieces;
int nargs;
@@ -2733,7 +2735,7 @@ maint_agent_printf_command (char *exp, i
cmdrest = exp;
- cmdrest = skip_spaces (cmdrest);
+ cmdrest = skip_spaces_const (cmdrest);
if (*cmdrest++ != '"')
error (_("Must start with a format string."));
@@ -2749,19 +2751,19 @@ maint_agent_printf_command (char *exp, i
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);
nargs = 0;
while (*cmdrest != '\0')
{
- char *cmd1;
+ const char *cmd1;
cmd1 = cmdrest;
expr = parse_exp_1 (&cmd1, 0, (struct block *) 0, 1);
Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.744
diff -u -p -r1.744 breakpoint.c
--- breakpoint.c 7 Mar 2013 21:57:29 -0000 1.744
+++ breakpoint.c 8 Mar 2013 00:52:44 -0000
@@ -950,7 +950,7 @@ set_breakpoint_condition (struct breakpo
}
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,
if (within_current_scope && reparse)
{
- char *s;
+ const char *s;
if (b->exp)
{
@@ -2186,8 +2186,8 @@ parse_cmd_to_aexpr (CORE_ADDR scope, cha
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, cha
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, cha
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, cha
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 *
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, CO
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, CO
return;
}
- end_tok = skip_to_space (tok);
+ end_tok = skip_to_space_const (tok);
toklen = end_tok - tok;
@@ -9414,11 +9415,13 @@ find_condition_and_thread (char *tok, CO
}
else if (toklen >= 1 && strncmp (tok, "thread", toklen) == 0)
{
- char *tmptok;
+ char *endp;
+ const char *tmptok;
tok = end_tok + 1;
tmptok = tok;
- *thread = strtol (tok, &tok, 0);
+ *thread = strtol (tok, &endp, 0);
+ tok = endp;
if (tok == tmptok)
error (_("Junk after thread keyword."));
if (!valid_thread_id (*thread))
@@ -9426,11 +9429,13 @@ find_condition_and_thread (char *tok, CO
}
else if (toklen >= 1 && strncmp (tok, "task", toklen) == 0)
{
- char *tmptok;
+ char *endp;
+ const char *tmptok;
tok = end_tok + 1;
tmptok = tok;
- *task = strtol (tok, &tok, 0);
+ *task = strtol (tok, &endp, 0);
+ tok = endp;
if (tok == tmptok)
error (_("Junk after task keyword."));
if (!valid_task_id (*task))
@@ -10845,12 +10850,12 @@ watch_command_1 (char *arg, int accessfl
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 +10864,19 @@ watch_command_1 (char *arg, int accessfl
int use_mask = 0;
CORE_ADDR mask = 0;
struct watchpoint *w;
+ const char *tmp, *start, *end_arg, *cbuf;
+ char *buf;
/* Make sure that we actually have parameters to parse. */
if (arg != NULL && arg[0] != '\0')
{
- char *value_start;
+ const char *value_start;
+
+ end_arg = 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 = end_arg - 1; tok > arg; tok--)
{
/* Skip whitespace at the end of the argument list. */
while (tok > arg && (*tok == ' ' || *tok == '\t'))
@@ -10937,15 +10946,22 @@ watch_command_1 (char *arg, int accessfl
/* 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';
+ end_arg = tok;
}
}
+ else
+ end_arg = arg;
/* Parse the rest of the arguments. */
innermost_block = NULL;
- exp_start = arg;
- exp = parse_exp_1 (&arg, 0, 0, 0);
- exp_end = arg;
+ buf = alloca (end_arg - arg + 1);
+ strncpy (buf, arg, end_arg - arg);
+ buf[end_arg - arg] = '\0';
+ exp_start = buf;
+ tmp = start = buf;
+ exp = parse_exp_1 (&tmp, 0, 0, 0);
+ cbuf = exp_end = exp_start + (tmp - start);
+
/* Remove trailing whitespace from the expression before saving it.
This makes the eventual display of the expression string a bit
prettier. */
@@ -10989,17 +11005,20 @@ watch_command_1 (char *arg, int accessfl
else if (val != NULL)
release_value (val);
- tok = skip_spaces (arg);
- end_tok = skip_to_space (tok);
+ tok = skip_spaces_const (cbuf);
+ end_tok = skip_to_space_const (tok);
toklen = end_tok - tok;
if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
{
struct expression *cond;
+ const char *tmp, *start;
innermost_block = NULL;
tok = cond_start = end_tok + 1;
- cond = parse_exp_1 (&tok, 0, 0, 0);
+ tmp = start = tok;
+ cond = parse_exp_1 (&tmp, 0, 0, 0);
+ tok += tmp - start;
/* The watchpoint expression may not be local, but the condition
may still be. E.g.: `watch global if local > 0'. */
@@ -14036,7 +14055,7 @@ update_breakpoint_locations (struct brea
old symtab. */
if (b->cond_string != NULL)
{
- char *s;
+ const char *s;
volatile struct gdb_exception e;
s = b->cond_string;
Index: eval.c
===================================================================
RCS file: /cvs/src/src/gdb/eval.c,v
retrieving revision 1.178
diff -u -p -r1.178 eval.c
--- eval.c 14 Feb 2013 12:43:45 -0000 1.178
+++ eval.c 8 Mar 2013 00:52:44 -0000
@@ -76,7 +76,7 @@ evaluate_subexp (struct type *expect_typ
and return the result as a number. */
CORE_ADDR
-parse_and_eval_address (char *exp)
+parse_and_eval_address (const char *exp)
{
struct expression *expr = parse_expression (exp);
CORE_ADDR addr;
@@ -121,7 +121,7 @@ parse_and_eval (char *exp)
EXPP is advanced to point to the comma. */
struct value *
-parse_to_comma_and_eval (char **expp)
+parse_to_comma_and_eval (const char **expp)
{
struct expression *expr = parse_exp_1 (expp, 0, (struct block *) 0, 1);
struct value *val;
Index: expression.h
===================================================================
RCS file: /cvs/src/src/gdb/expression.h,v
retrieving revision 1.47
diff -u -p -r1.47 expression.h
--- expression.h 1 Jan 2013 06:32:42 -0000 1.47
+++ expression.h 8 Mar 2013 00:52:44 -0000
@@ -95,12 +95,12 @@ struct expression
/* From parse.c */
-extern struct expression *parse_expression (char *);
+extern struct expression *parse_expression (const char *);
extern struct type *parse_expression_for_completion (char *, char **,
enum type_code *);
-extern struct expression *parse_exp_1 (char **, CORE_ADDR pc,
+extern struct expression *parse_exp_1 (const char **, CORE_ADDR pc,
const struct block *, int);
/* For use by parsers; set if we want to parse an expression and
Index: findcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/findcmd.c,v
retrieving revision 1.22
diff -u -p -r1.22 findcmd.c
--- findcmd.c 7 Mar 2013 21:57:29 -0000 1.22
+++ findcmd.c 8 Mar 2013 00:52:44 -0000
@@ -69,7 +69,7 @@ parse_find_args (char *args, ULONGEST *m
ULONGEST pattern_len;
CORE_ADDR start_addr;
ULONGEST search_space_len;
- char *s = args;
+ const char *s = args;
struct cleanup *old_cleanups;
struct value *v;
@@ -110,7 +110,7 @@ parse_find_args (char *args, ULONGEST *m
}
}
- s = skip_spaces (s);
+ s = skip_spaces_const (s);
}
/* Get the search range. */
@@ -120,7 +120,7 @@ parse_find_args (char *args, ULONGEST *m
if (*s == ',')
++s;
- s = skip_spaces (s);
+ s = skip_spaces_const (s);
if (*s == '+')
{
@@ -171,7 +171,7 @@ parse_find_args (char *args, ULONGEST *m
struct type *t;
ULONGEST pattern_buf_size_need;
- s = skip_spaces (s);
+ s = skip_spaces_const (s);
v = parse_to_comma_and_eval (&s);
t = value_type (v);
@@ -219,7 +219,7 @@ parse_find_args (char *args, ULONGEST *m
if (*s == ',')
++s;
- s = skip_spaces (s);
+ s = skip_spaces_const (s);
}
if (pattern_buf_end == pattern_buf)
Index: linespec.c
===================================================================
RCS file: /cvs/src/src/gdb/linespec.c,v
retrieving revision 1.180
diff -u -p -r1.180 linespec.c
--- linespec.c 6 Mar 2013 11:05:54 -0000 1.180
+++ linespec.c 8 Mar 2013 00:52:44 -0000
@@ -326,7 +326,7 @@ static void iterate_over_file_blocks (st
static void initialize_defaults (struct symtab **default_symtab,
int *default_line);
-static CORE_ADDR linespec_expression_to_pc (char **exp_ptr);
+static CORE_ADDR linespec_expression_to_pc (const char **exp_ptr);
static struct symtabs_and_lines decode_objc (struct linespec_state *self,
linespec_p ls,
@@ -2181,7 +2181,8 @@ parse_linespec (linespec_parser *parser,
/* It must be either LSTOKEN_STRING or LSTOKEN_NUMBER. */
if (token.type == LSTOKEN_STRING && *LS_TOKEN_STOKEN (token).ptr == '*')
{
- char *expr, *copy;
+ char *expr;
+ const char *copy;
/* User specified an expression, *EXPR. */
copy = expr = copy_token_string (token);
@@ -2565,7 +2566,7 @@ initialize_defaults (struct symtab **def
advancing EXP_PTR past any parsed text. */
static CORE_ADDR
-linespec_expression_to_pc (char **exp_ptr)
+linespec_expression_to_pc (const char **exp_ptr)
{
if (current_program_space->executing_startup)
/* The error message doesn't really matter, because this case
Index: parse.c
===================================================================
RCS file: /cvs/src/src/gdb/parse.c,v
retrieving revision 1.135
diff -u -p -r1.135 parse.c
--- parse.c 13 Jan 2013 18:57:00 -0000 1.135
+++ parse.c 8 Mar 2013 00:52:44 -0000
@@ -1125,10 +1125,18 @@ prefixify_subexp (struct expression *ine
If COMMA is nonzero, stop if a comma is reached. */
struct expression *
-parse_exp_1 (char **stringptr, CORE_ADDR pc, const struct block *block,
+parse_exp_1 (const char **stringptr, CORE_ADDR pc, const struct block *block,
int comma)
{
- return parse_exp_in_context (stringptr, pc, block, comma, 0, NULL);
+ struct expression *expr;
+ char *const_hack = *stringptr ? xstrdup (*stringptr) : NULL;
+ char *orig = const_hack;
+ struct cleanup *back_to = make_cleanup (xfree, const_hack);
+
+ expr = parse_exp_in_context (&const_hack, pc, block, comma, 0, NULL);
+ (*stringptr) += const_hack - orig;
+ do_cleanups (back_to);
+ return expr;
}
/* As for parse_exp_1, except that if VOID_CONTEXT_P, then
@@ -1264,7 +1272,7 @@ parse_exp_in_context (char **stringptr,
to use up all of the contents of STRING. */
struct expression *
-parse_expression (char *string)
+parse_expression (const char *string)
{
struct expression *exp;
Index: printcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/printcmd.c,v
retrieving revision 1.223
diff -u -p -r1.223 printcmd.c
--- printcmd.c 11 Feb 2013 22:44:23 -0000 1.223
+++ printcmd.c 8 Mar 2013 00:52:44 -0000
@@ -2215,10 +2215,10 @@ printf_pointer (struct ui_file *stream,
/* printf "printf format string" ARG to STREAM. */
static void
-ui_printf (char *arg, struct ui_file *stream)
+ui_printf (const char *arg, struct ui_file *stream)
{
struct format_piece *fpieces;
- char *s = arg;
+ const char *s = arg;
struct value **val_args;
int allocated_args = 20;
struct cleanup *old_cleanups;
@@ -2229,7 +2229,7 @@ ui_printf (char *arg, struct ui_file *st
if (s == 0)
error_no_arg (_("format-control string and values to print"));
- s = skip_spaces (s);
+ s = skip_spaces_const (s);
/* A format string should follow, enveloped in double quotes. */
if (*s++ != '"')
@@ -2242,14 +2242,14 @@ ui_printf (char *arg, struct ui_file *st
if (*s++ != '"')
error (_("Bad format string, non-terminated '\"'."));
- s = skip_spaces (s);
+ s = skip_spaces_const (s);
if (*s != ',' && *s != 0)
error (_("Invalid argument syntax"));
if (*s == ',')
s++;
- s = skip_spaces (s);
+ s = skip_spaces_const (s);
{
int nargs = 0;
@@ -2267,7 +2267,7 @@ ui_printf (char *arg, struct ui_file *st
while (*s != '\0')
{
- char *s1;
+ const char *s1;
if (nargs == allocated_args)
val_args = (struct value **) xrealloc ((char *) val_args,
Index: tracepoint.c
===================================================================
RCS file: /cvs/src/src/gdb/tracepoint.c,v
retrieving revision 1.283
diff -u -p -r1.283 tracepoint.c
--- tracepoint.c 7 Mar 2013 21:57:30 -0000 1.283
+++ tracepoint.c 8 Mar 2013 00:52:44 -0000
@@ -749,9 +749,13 @@ validate_actionline (char **line, struct
tmp_p = p;
for (loc = t->base.loc; loc; loc = loc->next)
{
- p = tmp_p;
- exp = parse_exp_1 (&p, loc->address,
+ const char *q, *o;
+
+ o = q = tmp_p;
+
+ exp = parse_exp_1 (&q, loc->address,
block_for_pc (loc->address), 1);
+ p += q - o;
old_chain = make_cleanup (free_current_contents, &exp);
if (exp->elts[0].opcode == OP_VAR_VALUE)
@@ -801,10 +805,13 @@ validate_actionline (char **line, struct
tmp_p = p;
for (loc = t->base.loc; loc; loc = loc->next)
{
- p = tmp_p;
+ const char *o, *q;
+
+ o = q = tmp_p;
/* Only expressions are allowed for this action. */
- exp = parse_exp_1 (&p, loc->address,
+ exp = parse_exp_1 (&q, loc->address,
block_for_pc (loc->address), 1);
+ p += q - o;
old_chain = make_cleanup (free_current_contents, &exp);
/* We have something to evaluate, make sure that the expr to
@@ -1465,9 +1472,12 @@ encode_actions_1 (struct command_line *a
unsigned long addr;
struct cleanup *old_chain = NULL;
struct cleanup *old_chain1 = NULL;
+ const char *q, *o;
- exp = parse_exp_1 (&action_exp, tloc->address,
+ o = q = action_exp;
+ exp = parse_exp_1 (&q, tloc->address,
block_for_pc (tloc->address), 1);
+ action_exp += q - o;
old_chain = make_cleanup (free_current_contents, &exp);
switch (exp->elts[0].opcode)
@@ -1556,9 +1566,12 @@ encode_actions_1 (struct command_line *a
{
struct cleanup *old_chain = NULL;
struct cleanup *old_chain1 = NULL;
+ const char *q, *o;
- exp = parse_exp_1 (&action_exp, tloc->address,
+ o = q = action_exp;
+ exp = parse_exp_1 (&q, tloc->address,
block_for_pc (tloc->address), 1);
+ action_exp += q - o;
old_chain = make_cleanup (free_current_contents, &exp);
aexpr = gen_eval_for_expr (tloc->address, exp);
Index: value.h
===================================================================
RCS file: /cvs/src/src/gdb/value.h,v
retrieving revision 1.217
diff -u -p -r1.217 value.h
--- value.h 6 Feb 2013 19:40:04 -0000 1.217
+++ value.h 8 Mar 2013 00:52:44 -0000
@@ -726,11 +726,11 @@ extern struct value *evaluate_subexp_wit
extern struct value *parse_and_eval (char *exp);
-extern struct value *parse_to_comma_and_eval (char **expp);
+extern struct value *parse_to_comma_and_eval (const char **expp);
extern struct type *parse_and_eval_type (char *p, int length);
-extern CORE_ADDR parse_and_eval_address (char *exp);
+extern CORE_ADDR parse_and_eval_address (const char *exp);
extern LONGEST parse_and_eval_long (char *exp);
Index: varobj.c
===================================================================
RCS file: /cvs/src/src/gdb/varobj.c,v
retrieving revision 1.205
diff -u -p -r1.205 varobj.c
--- varobj.c 7 Mar 2013 19:24:32 -0000 1.205
+++ varobj.c 8 Mar 2013 00:52:44 -0000
@@ -620,7 +620,7 @@ varobj_create (char *objname,
struct frame_info *fi;
struct frame_id old_id = null_frame_id;
struct block *block;
- char *p;
+ const char *p;
enum varobj_languages lang;
struct value *value = NULL;
volatile struct gdb_exception except;
@@ -1469,7 +1469,7 @@ varobj_set_value (struct varobj *var, ch
struct expression *exp;
struct value *value = NULL; /* Initialize to keep gcc happy. */
int saved_input_radix = input_radix;
- char *s = expression;
+ const char *s = expression;
volatile struct gdb_exception except;
gdb_assert (varobj_editable_p (var));
Index: cli/cli-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-cmds.c,v
retrieving revision 1.150
diff -u -p -r1.150 cli-cmds.c
--- cli/cli-cmds.c 7 Mar 2013 21:57:30 -0000 1.150
+++ cli/cli-cmds.c 8 Mar 2013 00:52:44 -0000
@@ -1113,20 +1113,22 @@ disassemble_command (char *arg, int from
const char *name;
CORE_ADDR pc;
int flags;
+ const char *p;
+ p = arg;
name = NULL;
flags = 0;
- if (arg && *arg == '/')
+ if (p && *p == '/')
{
- ++arg;
+ ++p;
- if (*arg == '\0')
+ if (*p == '\0')
error (_("Missing modifier."));
- while (*arg && ! isspace (*arg))
+ while (*p && ! isspace (*p))
{
- switch (*arg++)
+ switch (*p++)
{
case 'm':
flags |= DISASSEMBLY_SOURCE;
@@ -1139,20 +1141,20 @@ disassemble_command (char *arg, int from
}
}
- arg = skip_spaces (arg);
+ p = skip_spaces_const (p);
}
- if (! arg || ! *arg)
+ if (! p || ! *p)
{
flags |= DISASSEMBLY_OMIT_FNAME;
disassemble_current_function (flags);
return;
}
- pc = value_as_address (parse_to_comma_and_eval (&arg));
- if (arg[0] == ',')
- ++arg;
- if (arg[0] == '\0')
+ pc = value_as_address (parse_to_comma_and_eval (&p));
+ if (p[0] == ',')
+ ++p;
+ if (p[0] == '\0')
{
/* One argument. */
if (find_pc_partial_function (pc, &name, &low, &high) == 0)
@@ -1172,13 +1174,13 @@ disassemble_command (char *arg, int from
/* Two arguments. */
int incl_flag = 0;
low = pc;
- arg = skip_spaces (arg);
- if (arg[0] == '+')
+ p = skip_spaces_const (p);
+ if (p[0] == '+')
{
- ++arg;
+ ++p;
incl_flag = 1;
}
- high = parse_and_eval_address (arg);
+ high = parse_and_eval_address (p);
if (incl_flag)
high += low;
}
Index: cli/cli-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-utils.c,v
retrieving revision 1.18
diff -u -p -r1.18 cli-utils.c
--- cli/cli-utils.c 12 Feb 2013 19:03:55 -0000 1.18
+++ cli/cli-utils.c 8 Mar 2013 00:52:44 -0000
@@ -237,8 +237,8 @@ skip_spaces_const (const char *chp)
/* See documentation in cli-utils.h. */
-char *
-skip_to_space (char *chp)
+const char *
+skip_to_space_const (const char *chp)
{
if (chp == NULL)
return NULL;
Index: cli/cli-utils.h
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-utils.h,v
retrieving revision 1.18
diff -u -p -r1.18 cli-utils.h
--- cli/cli-utils.h 12 Feb 2013 19:03:55 -0000 1.18
+++ cli/cli-utils.h 8 Mar 2013 00:52:44 -0000
@@ -101,7 +101,9 @@ extern const char *skip_spaces_const (co
/* Skip leading non-whitespace characters in INP, returning an updated
pointer. If INP is NULL, return NULL. */
-extern char *skip_to_space (char *inp);
+#define skip_to_space(INP) ((char *) skip_to_space_const ((INP)))
+
+extern const char *skip_to_space_const (const char *inp);
/* Reverse S to the last non-whitespace character without skipping past
START. */
Index: common/format.c
===================================================================
RCS file: /cvs/src/src/gdb/common/format.c,v
retrieving revision 1.3
diff -u -p -r1.3 format.c
--- common/format.c 8 Feb 2013 22:52:20 -0000 1.3
+++ common/format.c 8 Mar 2013 00:52:44 -0000
@@ -28,11 +28,12 @@
#include "format.h"
struct format_piece *
-parse_format_string (char **arg)
+parse_format_string (const char **arg)
{
- char *s, *f, *string;
- char *prev_start;
- char *percent_loc;
+ const char *s;
+ char *f, *string;
+ const char *prev_start;
+ const char *percent_loc;
char *sub_start, *current_substring;
struct format_piece *pieces;
int next_frag;
Index: common/format.h
===================================================================
RCS file: /cvs/src/src/gdb/common/format.h,v
retrieving revision 1.2
diff -u -p -r1.2 format.h
--- common/format.h 1 Jan 2013 06:32:54 -0000 1.2
+++ common/format.h 8 Mar 2013 00:52:44 -0000
@@ -51,7 +51,7 @@ struct format_piece
/* Return an array of printf fragments found at the given string, and
rewrite ARG with a pointer to the end of the format string. */
-extern struct format_piece *parse_format_string (char **arg);
+extern struct format_piece *parse_format_string (const char **arg);
/* Given a pointer to an array of format pieces, free any memory that
would have been allocated by parse_format_string. */
Index: gdbserver/ax.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/ax.c,v
retrieving revision 1.6
diff -u -p -r1.6 ax.c
--- gdbserver/ax.c 18 Jan 2013 06:40:57 -0000 1.6
+++ gdbserver/ax.c 8 Mar 2013 00:52:44 -0000
@@ -798,10 +798,10 @@ compile_bytecodes (struct agent_expr *ae
in. */
static void
-ax_printf (CORE_ADDR fn, CORE_ADDR chan, char *format,
+ax_printf (CORE_ADDR fn, CORE_ADDR chan, const char *format,
int nargs, ULONGEST *args)
{
- char *f = format;
+ const char *f = format;
struct format_piece *fpieces;
int i, fp;
char *current_substring;