* 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.
This commit is contained in:
Keith Seitz 2013-03-12 17:39:45 +00:00
parent f3cec7e61f
commit bbc13ae3db
20 changed files with 207 additions and 109 deletions

View File

@ -1,3 +1,64 @@
2013-03-12 Keith Seitz <keiths@redhat.com>
* 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.
2013-03-12 Hui Zhu <hui@codesourcery.com>
* dwarf2loc.c (dwarf2_compile_expr_to_ax): Update error message.

View File

@ -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_catchpoint *c)
if (!bl->shlib_disabled)
{
volatile struct gdb_exception e;
char *s;
const char *s;
s = cond_string;
TRY_CATCH (e, RETURN_MASK_ERROR)

View File

@ -2608,6 +2608,7 @@ agent_eval_command_one (char *exp, int eval, CORE_ADDR pc)
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 eval, CORE_ADDR pc)
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, int from_tty)
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, int from_tty)
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, int from_tty)
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);

View File

@ -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;

View File

@ -1113,20 +1113,22 @@ disassemble_command (char *arg, int from_tty)
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_tty)
}
}
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_tty)
/* 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;
}

View File

@ -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;

View File

@ -101,7 +101,11 @@ extern const char *skip_spaces_const (const char *inp);
/* 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))
/* A const-correct version of the above. */
extern const char *skip_to_space_const (const char *inp);
/* Reverse S to the last non-whitespace character without skipping past
START. */

View File

@ -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;

View File

@ -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. */

View File

@ -76,7 +76,7 @@ evaluate_subexp (struct type *expect_type, struct expression *exp,
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;
@ -104,7 +104,7 @@ parse_and_eval_long (char *exp)
}
struct value *
parse_and_eval (char *exp)
parse_and_eval (const char *exp)
{
struct expression *expr = parse_expression (exp);
struct value *val;
@ -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;

View File

@ -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

View File

@ -69,7 +69,7 @@ parse_find_args (char *args, ULONGEST *max_countp,
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 *max_countp,
}
}
s = skip_spaces (s);
s = skip_spaces_const (s);
}
/* Get the search range. */
@ -120,7 +120,7 @@ parse_find_args (char *args, ULONGEST *max_countp,
if (*s == ',')
++s;
s = skip_spaces (s);
s = skip_spaces_const (s);
if (*s == '+')
{
@ -171,7 +171,7 @@ parse_find_args (char *args, ULONGEST *max_countp,
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 *max_countp,
if (*s == ',')
++s;
s = skip_spaces (s);
s = skip_spaces_const (s);
}
if (pattern_buf_end == pattern_buf)

View File

@ -798,10 +798,10 @@ compile_bytecodes (struct agent_expr *aexpr)
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;

View File

@ -326,7 +326,7 @@ static void iterate_over_file_blocks (struct symtab *symtab,
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, char **argptr)
/* 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 **default_symtab, int *default_line)
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

View File

@ -1125,10 +1125,18 @@ prefixify_subexp (struct expression *inexpr,
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, CORE_ADDR pc, const struct block *block,
to use up all of the contents of STRING. */
struct expression *
parse_expression (char *string)
parse_expression (const char *string)
{
struct expression *exp;

View File

@ -2215,10 +2215,10 @@ printf_pointer (struct ui_file *stream, const char *format,
/* 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 *stream)
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 *stream)
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 *stream)
while (*s != '\0')
{
char *s1;
const char *s1;
if (nargs == allocated_args)
val_args = (struct value **) xrealloc ((char *) val_args,

View File

@ -720,11 +720,7 @@ gdbpy_parse_and_eval (PyObject *self, PyObject *args)
TRY_CATCH (except, RETURN_MASK_ALL)
{
char *copy = xstrdup (expr_str);
struct cleanup *cleanup = make_cleanup (xfree, copy);
result = parse_and_eval (copy);
do_cleanups (cleanup);
result = parse_and_eval (expr_str);
}
GDB_PY_HANDLE_EXCEPTION (except);

View File

@ -754,9 +754,12 @@ validate_actionline (char **line, struct breakpoint *b)
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;
q = tmp_p;
exp = parse_exp_1 (&q, loc->address,
block_for_pc (loc->address), 1);
p = (char *) q;
old_chain = make_cleanup (free_current_contents, &exp);
if (exp->elts[0].opcode == OP_VAR_VALUE)
@ -806,10 +809,13 @@ validate_actionline (char **line, struct breakpoint *b)
tmp_p = p;
for (loc = t->base.loc; loc; loc = loc->next)
{
p = tmp_p;
const char *q;
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 = (char *) q;
old_chain = make_cleanup (free_current_contents, &exp);
/* We have something to evaluate, make sure that the expr to
@ -1470,9 +1476,12 @@ encode_actions_1 (struct command_line *action,
unsigned long addr;
struct cleanup *old_chain = NULL;
struct cleanup *old_chain1 = NULL;
const char *q;
exp = parse_exp_1 (&action_exp, tloc->address,
q = action_exp;
exp = parse_exp_1 (&q, tloc->address,
block_for_pc (tloc->address), 1);
action_exp = (char *) q;
old_chain = make_cleanup (free_current_contents, &exp);
switch (exp->elts[0].opcode)
@ -1561,9 +1570,12 @@ encode_actions_1 (struct command_line *action,
{
struct cleanup *old_chain = NULL;
struct cleanup *old_chain1 = NULL;
const char *q;
exp = parse_exp_1 (&action_exp, tloc->address,
q = action_exp;
exp = parse_exp_1 (&q, tloc->address,
block_for_pc (tloc->address), 1);
action_exp = (char *) q;
old_chain = make_cleanup (free_current_contents, &exp);
aexpr = gen_eval_for_expr (tloc->address, exp);

View File

@ -724,13 +724,13 @@ extern char *extract_field_op (struct expression *exp, int *subexp);
extern struct value *evaluate_subexp_with_coercion (struct expression *,
int *, enum noside);
extern struct value *parse_and_eval (char *exp);
extern struct value *parse_and_eval (const 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);

View File

@ -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, char *expression)
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));