Fix FIXME: xstrdup should not be here
Hi, This FIXME goes into my eyes, when I am about to modify something here, /* Name is allocated by name_of_child. */ /* FIXME: xstrdup should not be here. */ This FIXME was introduced in the python pretty-pretter patches. Python pretty-printing [6/6] https://sourceware.org/ml/gdb-patches/2009-05/msg00467.html create_child_with_value is called in two paths, 1. varobj_list_children -> create_child -> create_child_with_value, 2. install_dynamic_child -> install_dynamic_child -> varobj_add_child -> create_child_with_value In path #1, 'name' is allocated by name_of_child, as the original comment said, we don't have to duplicate NAME in create_child_with_value. In path #2, 'name' is got from PyArg_ParseTuple, and we have to duplicate NAME. This patch removes the call to xstrdup in create_child_with_value and call xstrudp in update_dynamic_varobj_children (path #2). gdb: 2013-10-04 Yao Qi <yao@codesourcery.com> * varobj.c (create_child_with_value): Remove 'const' from the type of parameter 'name'. (varobj_add_child): Likewise. (install_dynamic_child): Remove 'const' from the type of parameter 'name'. (varobj_add_child): Likewise. (create_child_with_value): Likewise. Update comments. Don't duplicate 'name'. (update_dynamic_varobj_children): Duplicate 'name' and pass it to install_dynamic_child.
This commit is contained in:
parent
c4c2eac59e
commit
5e5ac9a570
|
@ -1,3 +1,16 @@
|
||||||
|
2013-10-04 Yao Qi <yao@codesourcery.com>
|
||||||
|
|
||||||
|
* varobj.c (create_child_with_value): Remove 'const' from the
|
||||||
|
type of parameter 'name'.
|
||||||
|
(varobj_add_child): Likewise.
|
||||||
|
(install_dynamic_child): Remove 'const' from the type of
|
||||||
|
parameter 'name'.
|
||||||
|
(varobj_add_child): Likewise.
|
||||||
|
(create_child_with_value): Likewise. Update comments. Don't
|
||||||
|
duplicate 'name'.
|
||||||
|
(update_dynamic_varobj_children): Duplicate 'name'
|
||||||
|
and pass it to install_dynamic_child.
|
||||||
|
|
||||||
2013-10-03 Phil Muldoon <pmuldoon@redhat.com>
|
2013-10-03 Phil Muldoon <pmuldoon@redhat.com>
|
||||||
|
|
||||||
* python/py-value.c (convert_value_from_python): Move PyInt_Check
|
* python/py-value.c (convert_value_from_python): Move PyInt_Check
|
||||||
|
|
18
gdb/varobj.c
18
gdb/varobj.c
|
@ -245,7 +245,7 @@ static void uninstall_variable (struct varobj *);
|
||||||
static struct varobj *create_child (struct varobj *, int, char *);
|
static struct varobj *create_child (struct varobj *, int, char *);
|
||||||
|
|
||||||
static struct varobj *
|
static struct varobj *
|
||||||
create_child_with_value (struct varobj *parent, int index, const char *name,
|
create_child_with_value (struct varobj *parent, int index, char *name,
|
||||||
struct value *value);
|
struct value *value);
|
||||||
|
|
||||||
/* Utility routines */
|
/* Utility routines */
|
||||||
|
@ -304,7 +304,7 @@ static int is_root_p (struct varobj *var);
|
||||||
#if HAVE_PYTHON
|
#if HAVE_PYTHON
|
||||||
|
|
||||||
static struct varobj *varobj_add_child (struct varobj *var,
|
static struct varobj *varobj_add_child (struct varobj *var,
|
||||||
const char *name,
|
char *name,
|
||||||
struct value *value);
|
struct value *value);
|
||||||
|
|
||||||
#endif /* HAVE_PYTHON */
|
#endif /* HAVE_PYTHON */
|
||||||
|
@ -994,7 +994,7 @@ install_dynamic_child (struct varobj *var,
|
||||||
VEC (varobj_p) **unchanged,
|
VEC (varobj_p) **unchanged,
|
||||||
int *cchanged,
|
int *cchanged,
|
||||||
int index,
|
int index,
|
||||||
const char *name,
|
char *name,
|
||||||
struct value *value)
|
struct value *value)
|
||||||
{
|
{
|
||||||
if (VEC_length (varobj_p, var->children) < index + 1)
|
if (VEC_length (varobj_p, var->children) < index + 1)
|
||||||
|
@ -1188,7 +1188,8 @@ update_dynamic_varobj_children (struct varobj *var,
|
||||||
can_mention ? type_changed : NULL,
|
can_mention ? type_changed : NULL,
|
||||||
can_mention ? new : NULL,
|
can_mention ? new : NULL,
|
||||||
can_mention ? unchanged : NULL,
|
can_mention ? unchanged : NULL,
|
||||||
can_mention ? cchanged : NULL, i, name, v);
|
can_mention ? cchanged : NULL, i,
|
||||||
|
xstrdup (name), v);
|
||||||
do_cleanups (inner);
|
do_cleanups (inner);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1307,7 +1308,7 @@ varobj_list_children (struct varobj *var, int *from, int *to)
|
||||||
#if HAVE_PYTHON
|
#if HAVE_PYTHON
|
||||||
|
|
||||||
static struct varobj *
|
static struct varobj *
|
||||||
varobj_add_child (struct varobj *var, const char *name, struct value *value)
|
varobj_add_child (struct varobj *var, char *name, struct value *value)
|
||||||
{
|
{
|
||||||
varobj_p v = create_child_with_value (var,
|
varobj_p v = create_child_with_value (var,
|
||||||
VEC_length (varobj_p, var->children),
|
VEC_length (varobj_p, var->children),
|
||||||
|
@ -2394,7 +2395,7 @@ is_anonymous_child (struct varobj *child)
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct varobj *
|
static struct varobj *
|
||||||
create_child_with_value (struct varobj *parent, int index, const char *name,
|
create_child_with_value (struct varobj *parent, int index, char *name,
|
||||||
struct value *value)
|
struct value *value)
|
||||||
{
|
{
|
||||||
struct varobj *child;
|
struct varobj *child;
|
||||||
|
@ -2402,9 +2403,8 @@ create_child_with_value (struct varobj *parent, int index, const char *name,
|
||||||
|
|
||||||
child = new_variable ();
|
child = new_variable ();
|
||||||
|
|
||||||
/* Name is allocated by name_of_child. */
|
/* NAME is allocated by caller. */
|
||||||
/* FIXME: xstrdup should not be here. */
|
child->name = name;
|
||||||
child->name = xstrdup (name);
|
|
||||||
child->index = index;
|
child->index = index;
|
||||||
child->parent = parent;
|
child->parent = parent;
|
||||||
child->root = parent->root;
|
child->root = parent->root;
|
||||||
|
|
Loading…
Reference in New Issue