* 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>
+ * 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>
+
* Makefile.in (HFILES_NO_SRCDIR): Add "common/" to
gdb_thread_db.h. Move all common/ entries to be together.
(TAGS): Don't depend on DEPFILES.
struct type *
lookup_typename (const struct language_defn *language,
- struct gdbarch *gdbarch, char *name,
+ struct gdbarch *gdbarch, const char *name,
const struct block *block, int noerr)
{
struct symbol *sym;
visible in lexical block BLOCK. */
struct type *
-lookup_struct (char *name, struct block *block)
+lookup_struct (const char *name, struct block *block)
{
struct symbol *sym;
visible in lexical block BLOCK. */
struct type *
-lookup_union (char *name, struct block *block)
+lookup_union (const char *name, struct block *block)
{
struct symbol *sym;
struct type *t;
visible in lexical block BLOCK. */
struct type *
-lookup_enum (char *name, struct block *block)
+lookup_enum (const char *name, struct block *block)
{
struct symbol *sym;
extern char *gdb_mangle_name (struct type *, int, int);
extern struct type *lookup_typename (const struct language_defn *,
- struct gdbarch *, char *,
+ struct gdbarch *, const char *,
const struct block *, int);
extern struct type *lookup_template_type (char *, struct type *,
bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *keywords[] = { "spec", "type", "wp_class", "internal", NULL };
- char *spec;
+ const char *spec;
int type = bp_breakpoint;
int access_type = hw_write;
PyObject *internal = NULL;
TRY_CATCH (except, RETURN_MASK_ALL)
{
+ char *copy = xstrdup (spec);
+ struct cleanup *cleanup = make_cleanup (xfree, copy);
+
switch (type)
{
case bp_breakpoint:
{
create_breakpoint (python_gdbarch,
- spec, NULL, -1,
+ copy, NULL, -1,
0,
0, bp_breakpoint,
0,
case bp_watchpoint:
{
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)
- awatch_command_wrapper (spec, 0, internal_bp);
+ awatch_command_wrapper (copy, 0, internal_bp);
else if (access_type == hw_read)
- rwatch_command_wrapper (spec, 0, internal_bp);
+ rwatch_command_wrapper (copy, 0, internal_bp);
else
error(_("Cannot understand watchpoint access type."));
break;
default:
error(_("Do not understand breakpoint type to set."));
}
+
+ do_cleanups (cleanup);
}
if (except.reason < 0)
{
cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
{
cmdpy_object *obj = (cmdpy_object *) self;
- char *name;
+ const char *name;
+ char *copy;
int cmdtype;
int completetype = -1;
char *docstring = NULL;
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)
return -1;
gdbpy_string_to_argv (PyObject *self, PyObject *args)
{
PyObject *py_argv;
- char *input;
+ const char *input;
if (!PyArg_ParseTuple (args, "s", &input))
return NULL;
static int
fnpy_init (PyObject *self, PyObject *args, PyObject *kwds)
{
- char *name, *docstring = NULL;
+ const char *name;
+ char *docstring = NULL;
if (! PyArg_ParseTuple (args, "s", &name))
return -1;
static PyObject *
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;
CORE_ADDR addr, length;
PyObject *addr_obj, *length_obj = NULL;
parmpy_init (PyObject *self, PyObject *args, PyObject *kwds)
{
parmpy_object *obj = (parmpy_object *) self;
- char *name;
+ const char *name;
+ char *copy;
char *set_doc, *show_doc, *doc;
char *cmd_name;
int parmclass, cmdtype;
obj->type = (enum var_types) parmclass;
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);
if (! cmd_name)
- return -1;
+ {
+ xfree (copy);
+ return -1;
+ }
xfree (cmd_name);
- cmd_name = gdbpy_parse_command_name (name, &show_list,
+ cmd_name = gdbpy_parse_command_name (copy, &show_list,
&showlist);
if (! cmd_name)
return -1;
+ xfree (copy);
set_doc = get_doc_string (self, set_doc_cst);
show_doc = get_doc_string (self, show_doc_cst);
for (i = 0; i < options->print_max; ++i)
{
PyObject *py_v, *item = PyIter_Next (iter);
- char *name;
+ const char *name;
struct cleanup *inner_cleanup;
if (! item)
}
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;
volatile struct gdb_exception except;
gdbpy_lookup_type (PyObject *self, PyObject *args, PyObject *kw)
{
static char *keywords[] = { "name", "block", NULL };
- char *type_name = NULL;
+ const char *type_name = NULL;
struct type *type = NULL;
PyObject *block_obj = NULL;
struct block *block = NULL;
gdbpy_parameter (PyObject *self, PyObject *args)
{
struct cmd_list_element *alias, *prefix, *cmd;
- char *arg, *newarg;
+ const char *arg;
+ char *newarg;
int found = -1;
volatile struct gdb_exception except;
static PyObject *
execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
{
- char *arg;
+ const char *arg;
PyObject *from_tty_obj = NULL, *to_string_obj = NULL;
int from_tty, to_string;
volatile struct gdb_exception except;
struct symtabs_and_lines sals = { NULL, 0 }; /* Initialize to
appease gcc. */
struct symtab_and_line sal;
- char *arg = NULL;
+ const char *arg = NULL;
char *copy = NULL;
struct cleanup *cleanups;
PyObject *result = NULL;
{
if (arg)
{
- arg = xstrdup (arg);
- make_cleanup (xfree, arg);
- copy = arg;
+ copy = xstrdup (arg);
+ make_cleanup (xfree, copy);
sals = decode_line_1 (©, 0, 0, 0, 0);
make_cleanup (xfree, sals.sals);
}
static PyObject *
gdbpy_parse_and_eval (PyObject *self, PyObject *args)
{
- char *expr_str;
+ const char *expr_str;
struct value *result = NULL;
volatile struct gdb_exception except;
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);
static PyObject *
gdbpy_write (PyObject *self, PyObject *args, PyObject *kw)
{
- char *arg;
+ const char *arg;
static char *keywords[] = {"text", "stream", NULL };
int stream_type = 0;
/* 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: */
if (to < 0 || i < to)
{
PyObject *py_v;
- char *name;
+ const char *name;
struct value *v;
struct cleanup *inner;
int can_mention = from < 0 || i >= from;