* varobj.c (update_dynamic_varobj_children): Make 'name' const.

* symtab.h (lookup_struct, lookup_union, lookup_enum): Update.
	* python/python.c (gdbpy_parameter): Make 'arg' const.
	(execute_gdb_command): Likewise.
	(gdbpy_decode_line): Likewise.  Copy it.
	(gdbpy_parse_and_eval): Make 'expr_string' const.  Copy it.
	(gdbpy_write): Make 'arg' const.
	* python/py-type.c (typy_lookup_typename): Make 'type_name'
	const.
	(gdbpy_lookup_type): Likewise.
	* python/py-prettyprint.c (print_children): Make 'name' const.
	* python/py-param.c (parmpy_init): Make 'name' const.  Copy it.
	* python/py-inferior.c (infpy_write_memory): Make 'buf_len' a
	Py_ssize_t.
	* python/py-function.c (fnpy_init): Make 'name' const.
	* python/py-cmd.c (cmdpy_init): Make 'name' const.  Copy it.
	(gdbpy_string_to_argv): Make 'input' const.
	* python/py-breakpoint.c (bppy_init): Make 'spec' const.  Copy
	it.
	* gdbtypes.h (lookup_typename): Update.
	* gdbtypes.c (lookup_typename): Make 'name' const.
	(lookup_struct): Likewise.
	(lookup_union): Likewise.
	(lookup_enum): Likewise.
This commit is contained in:
Tom Tromey 2011-06-24 19:47:37 +00:00
parent 5998129b54
commit ddd49eeec4
13 changed files with 82 additions and 35 deletions

View file

@ -1,3 +1,30 @@
2011-06-24 Tom Tromey <tromey@redhat.com>
* varobj.c (update_dynamic_varobj_children): Make 'name' const.
* symtab.h (lookup_struct, lookup_union, lookup_enum): Update.
* python/python.c (gdbpy_parameter): Make 'arg' const.
(execute_gdb_command): Likewise.
(gdbpy_decode_line): Likewise. Copy it.
(gdbpy_parse_and_eval): Make 'expr_string' const. Copy it.
(gdbpy_write): Make 'arg' const.
* python/py-type.c (typy_lookup_typename): Make 'type_name'
const.
(gdbpy_lookup_type): Likewise.
* python/py-prettyprint.c (print_children): Make 'name' const.
* python/py-param.c (parmpy_init): Make 'name' const. Copy it.
* python/py-inferior.c (infpy_write_memory): Make 'buf_len' a
Py_ssize_t.
* python/py-function.c (fnpy_init): Make 'name' const.
* python/py-cmd.c (cmdpy_init): Make 'name' const. Copy it.
(gdbpy_string_to_argv): Make 'input' const.
* python/py-breakpoint.c (bppy_init): Make 'spec' const. Copy
it.
* gdbtypes.h (lookup_typename): Update.
* gdbtypes.c (lookup_typename): Make 'name' const.
(lookup_struct): Likewise.
(lookup_union): Likewise.
(lookup_enum): Likewise.
2011-06-24 Tom Tromey <tromey@redhat.com> 2011-06-24 Tom Tromey <tromey@redhat.com>
* Makefile.in (HFILES_NO_SRCDIR): Add "common/" to * Makefile.in (HFILES_NO_SRCDIR): Add "common/" to

View file

@ -1137,7 +1137,7 @@ type_name_no_tag_or_error (struct type *type)
struct type * struct type *
lookup_typename (const struct language_defn *language, lookup_typename (const struct language_defn *language,
struct gdbarch *gdbarch, char *name, struct gdbarch *gdbarch, const char *name,
const struct block *block, int noerr) const struct block *block, int noerr)
{ {
struct symbol *sym; struct symbol *sym;
@ -1194,7 +1194,7 @@ lookup_signed_typename (const struct language_defn *language,
visible in lexical block BLOCK. */ visible in lexical block BLOCK. */
struct type * struct type *
lookup_struct (char *name, struct block *block) lookup_struct (const char *name, struct block *block)
{ {
struct symbol *sym; struct symbol *sym;
@ -1216,7 +1216,7 @@ lookup_struct (char *name, struct block *block)
visible in lexical block BLOCK. */ visible in lexical block BLOCK. */
struct type * struct type *
lookup_union (char *name, struct block *block) lookup_union (const char *name, struct block *block)
{ {
struct symbol *sym; struct symbol *sym;
struct type *t; struct type *t;
@ -1241,7 +1241,7 @@ lookup_union (char *name, struct block *block)
visible in lexical block BLOCK. */ visible in lexical block BLOCK. */
struct type * struct type *
lookup_enum (char *name, struct block *block) lookup_enum (const char *name, struct block *block)
{ {
struct symbol *sym; struct symbol *sym;

View file

@ -1405,7 +1405,7 @@ extern void check_stub_method_group (struct type *, int);
extern char *gdb_mangle_name (struct type *, int, int); extern char *gdb_mangle_name (struct type *, int, int);
extern struct type *lookup_typename (const struct language_defn *, extern struct type *lookup_typename (const struct language_defn *,
struct gdbarch *, char *, struct gdbarch *, const char *,
const struct block *, int); const struct block *, int);
extern struct type *lookup_template_type (char *, struct type *, extern struct type *lookup_template_type (char *, struct type *,

View file

@ -599,7 +599,7 @@ static int
bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
{ {
static char *keywords[] = { "spec", "type", "wp_class", "internal", NULL }; static char *keywords[] = { "spec", "type", "wp_class", "internal", NULL };
char *spec; const char *spec;
int type = bp_breakpoint; int type = bp_breakpoint;
int access_type = hw_write; int access_type = hw_write;
PyObject *internal = NULL; PyObject *internal = NULL;
@ -623,12 +623,15 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
TRY_CATCH (except, RETURN_MASK_ALL) TRY_CATCH (except, RETURN_MASK_ALL)
{ {
char *copy = xstrdup (spec);
struct cleanup *cleanup = make_cleanup (xfree, copy);
switch (type) switch (type)
{ {
case bp_breakpoint: case bp_breakpoint:
{ {
create_breakpoint (python_gdbarch, create_breakpoint (python_gdbarch,
spec, NULL, -1, copy, NULL, -1,
0, 0,
0, bp_breakpoint, 0, bp_breakpoint,
0, 0,
@ -639,11 +642,11 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
case bp_watchpoint: case bp_watchpoint:
{ {
if (access_type == hw_write) if (access_type == hw_write)
watch_command_wrapper (spec, 0, internal_bp); watch_command_wrapper (copy, 0, internal_bp);
else if (access_type == hw_access) else if (access_type == hw_access)
awatch_command_wrapper (spec, 0, internal_bp); awatch_command_wrapper (copy, 0, internal_bp);
else if (access_type == hw_read) else if (access_type == hw_read)
rwatch_command_wrapper (spec, 0, internal_bp); rwatch_command_wrapper (copy, 0, internal_bp);
else else
error(_("Cannot understand watchpoint access type.")); error(_("Cannot understand watchpoint access type."));
break; break;
@ -651,6 +654,8 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
default: default:
error(_("Do not understand breakpoint type to set.")); error(_("Do not understand breakpoint type to set."));
} }
do_cleanups (cleanup);
} }
if (except.reason < 0) if (except.reason < 0)
{ {

View file

@ -405,7 +405,8 @@ static int
cmdpy_init (PyObject *self, PyObject *args, PyObject *kw) cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
{ {
cmdpy_object *obj = (cmdpy_object *) self; cmdpy_object *obj = (cmdpy_object *) self;
char *name; const char *name;
char *copy;
int cmdtype; int cmdtype;
int completetype = -1; int completetype = -1;
char *docstring = NULL; char *docstring = NULL;
@ -449,7 +450,9 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
return -1; return -1;
} }
cmd_name = gdbpy_parse_command_name (name, &cmd_list, &cmdlist); copy = xstrdup (name);
cmd_name = gdbpy_parse_command_name (copy, &cmd_list, &cmdlist);
xfree (copy);
if (! cmd_name) if (! cmd_name)
return -1; return -1;
@ -659,7 +662,7 @@ PyObject *
gdbpy_string_to_argv (PyObject *self, PyObject *args) gdbpy_string_to_argv (PyObject *self, PyObject *args)
{ {
PyObject *py_argv; PyObject *py_argv;
char *input; const char *input;
if (!PyArg_ParseTuple (args, "s", &input)) if (!PyArg_ParseTuple (args, "s", &input))
return NULL; return NULL;

View file

@ -150,7 +150,8 @@ fnpy_call (struct gdbarch *gdbarch, const struct language_defn *language,
static int static int
fnpy_init (PyObject *self, PyObject *args, PyObject *kwds) fnpy_init (PyObject *self, PyObject *args, PyObject *kwds)
{ {
char *name, *docstring = NULL; const char *name;
char *docstring = NULL;
if (! PyArg_ParseTuple (args, "s", &name)) if (! PyArg_ParseTuple (args, "s", &name))
return -1; return -1;

View file

@ -428,7 +428,8 @@ infpy_read_memory (PyObject *self, PyObject *args, PyObject *kw)
static PyObject * static PyObject *
infpy_write_memory (PyObject *self, PyObject *args, PyObject *kw) infpy_write_memory (PyObject *self, PyObject *args, PyObject *kw)
{ {
int buf_len, error = 0; Py_ssize_t buf_len;
int error = 0;
const char *buffer; const char *buffer;
CORE_ADDR addr, length; CORE_ADDR addr, length;
PyObject *addr_obj, *length_obj = NULL; PyObject *addr_obj, *length_obj = NULL;

View file

@ -645,7 +645,8 @@ static int
parmpy_init (PyObject *self, PyObject *args, PyObject *kwds) parmpy_init (PyObject *self, PyObject *args, PyObject *kwds)
{ {
parmpy_object *obj = (parmpy_object *) self; parmpy_object *obj = (parmpy_object *) self;
char *name; const char *name;
char *copy;
char *set_doc, *show_doc, *doc; char *set_doc, *show_doc, *doc;
char *cmd_name; char *cmd_name;
int parmclass, cmdtype; int parmclass, cmdtype;
@ -696,16 +697,21 @@ parmpy_init (PyObject *self, PyObject *args, PyObject *kwds)
obj->type = (enum var_types) parmclass; obj->type = (enum var_types) parmclass;
memset (&obj->value, 0, sizeof (obj->value)); memset (&obj->value, 0, sizeof (obj->value));
cmd_name = gdbpy_parse_command_name (name, &set_list, copy = xstrdup (name);
cmd_name = gdbpy_parse_command_name (copy, &set_list,
&setlist); &setlist);
if (! cmd_name) if (! cmd_name)
{
xfree (copy);
return -1; return -1;
}
xfree (cmd_name); xfree (cmd_name);
cmd_name = gdbpy_parse_command_name (name, &show_list, cmd_name = gdbpy_parse_command_name (copy, &show_list,
&showlist); &showlist);
if (! cmd_name) if (! cmd_name)
return -1; return -1;
xfree (copy);
set_doc = get_doc_string (self, set_doc_cst); set_doc = get_doc_string (self, set_doc_cst);
show_doc = get_doc_string (self, show_doc_cst); show_doc = get_doc_string (self, show_doc_cst);

View file

@ -526,7 +526,7 @@ print_children (PyObject *printer, const char *hint,
for (i = 0; i < options->print_max; ++i) for (i = 0; i < options->print_max; ++i)
{ {
PyObject *py_v, *item = PyIter_Next (iter); PyObject *py_v, *item = PyIter_Next (iter);
char *name; const char *name;
struct cleanup *inner_cleanup; struct cleanup *inner_cleanup;
if (! item) if (! item)

View file

@ -497,7 +497,7 @@ typy_get_sizeof (PyObject *self, void *closure)
} }
static struct type * static struct type *
typy_lookup_typename (char *type_name, struct block *block) typy_lookup_typename (const char *type_name, struct block *block)
{ {
struct type *type = NULL; struct type *type = NULL;
volatile struct gdb_exception except; volatile struct gdb_exception except;
@ -1020,7 +1020,7 @@ PyObject *
gdbpy_lookup_type (PyObject *self, PyObject *args, PyObject *kw) gdbpy_lookup_type (PyObject *self, PyObject *args, PyObject *kw)
{ {
static char *keywords[] = { "name", "block", NULL }; static char *keywords[] = { "name", "block", NULL };
char *type_name = NULL; const char *type_name = NULL;
struct type *type = NULL; struct type *type = NULL;
PyObject *block_obj = NULL; PyObject *block_obj = NULL;
struct block *block = NULL; struct block *block = NULL;

View file

@ -290,7 +290,8 @@ PyObject *
gdbpy_parameter (PyObject *self, PyObject *args) gdbpy_parameter (PyObject *self, PyObject *args)
{ {
struct cmd_list_element *alias, *prefix, *cmd; struct cmd_list_element *alias, *prefix, *cmd;
char *arg, *newarg; const char *arg;
char *newarg;
int found = -1; int found = -1;
volatile struct gdb_exception except; volatile struct gdb_exception except;
@ -340,7 +341,7 @@ gdbpy_target_wide_charset (PyObject *self, PyObject *args)
static PyObject * static PyObject *
execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
{ {
char *arg; const char *arg;
PyObject *from_tty_obj = NULL, *to_string_obj = NULL; PyObject *from_tty_obj = NULL, *to_string_obj = NULL;
int from_tty, to_string; int from_tty, to_string;
volatile struct gdb_exception except; volatile struct gdb_exception except;
@ -434,7 +435,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
struct symtabs_and_lines sals = { NULL, 0 }; /* Initialize to struct symtabs_and_lines sals = { NULL, 0 }; /* Initialize to
appease gcc. */ appease gcc. */
struct symtab_and_line sal; struct symtab_and_line sal;
char *arg = NULL; const char *arg = NULL;
char *copy = NULL; char *copy = NULL;
struct cleanup *cleanups; struct cleanup *cleanups;
PyObject *result = NULL; PyObject *result = NULL;
@ -451,9 +452,8 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
{ {
if (arg) if (arg)
{ {
arg = xstrdup (arg); copy = xstrdup (arg);
make_cleanup (xfree, arg); make_cleanup (xfree, copy);
copy = arg;
sals = decode_line_1 (&copy, 0, 0, 0, 0); sals = decode_line_1 (&copy, 0, 0, 0, 0);
make_cleanup (xfree, sals.sals); make_cleanup (xfree, sals.sals);
} }
@ -531,7 +531,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
static PyObject * static PyObject *
gdbpy_parse_and_eval (PyObject *self, PyObject *args) gdbpy_parse_and_eval (PyObject *self, PyObject *args)
{ {
char *expr_str; const char *expr_str;
struct value *result = NULL; struct value *result = NULL;
volatile struct gdb_exception except; volatile struct gdb_exception except;
@ -540,7 +540,11 @@ gdbpy_parse_and_eval (PyObject *self, PyObject *args)
TRY_CATCH (except, RETURN_MASK_ALL) TRY_CATCH (except, RETURN_MASK_ALL)
{ {
result = parse_and_eval (expr_str); char *copy = xstrdup (expr_str);
struct cleanup *cleanup = make_cleanup (xfree, copy);
result = parse_and_eval (copy);
do_cleanups (cleanup);
} }
GDB_PY_HANDLE_EXCEPTION (except); GDB_PY_HANDLE_EXCEPTION (except);
@ -687,7 +691,7 @@ gdbpy_initialize_events (void)
static PyObject * static PyObject *
gdbpy_write (PyObject *self, PyObject *args, PyObject *kw) gdbpy_write (PyObject *self, PyObject *args, PyObject *kw)
{ {
char *arg; const char *arg;
static char *keywords[] = {"text", "stream", NULL }; static char *keywords[] = {"text", "stream", NULL };
int stream_type = 0; int stream_type = 0;

View file

@ -934,11 +934,11 @@ extern struct symbol *lookup_block_symbol (const struct block *, const char *,
/* lookup a [struct, union, enum] by name, within a specified block. */ /* lookup a [struct, union, enum] by name, within a specified block. */
extern struct type *lookup_struct (char *, struct block *); extern struct type *lookup_struct (const char *, struct block *);
extern struct type *lookup_union (char *, struct block *); extern struct type *lookup_union (const char *, struct block *);
extern struct type *lookup_enum (char *, struct block *); extern struct type *lookup_enum (const char *, struct block *);
/* from blockframe.c: */ /* from blockframe.c: */

View file

@ -1085,7 +1085,7 @@ update_dynamic_varobj_children (struct varobj *var,
if (to < 0 || i < to) if (to < 0 || i < to)
{ {
PyObject *py_v; PyObject *py_v;
char *name; const char *name;
struct value *v; struct value *v;
struct cleanup *inner; struct cleanup *inner;
int can_mention = from < 0 || i >= from; int can_mention = from < 0 || i >= from;