Iterate over 'struct varobj_item' instead of PyObject
In previous patch, "saved_item" is still a PyOjbect and iteration is still performed over PyObject. This patch continues to decouple iteration from python code, so it changes its type to "struct varobj_item *", so that the iterator itself is independent of python. V2: - Call varobj_delete_iter in free_variable. - Fix changelog entries. - Use XNEW. V3: - Return NULL early in py_varobj_iter_next if gdb_python_initialized is false. gdb: 2014-06-12 Pedro Alves <pedro@codesourcery.com> Yao Qi <yao@codesourcery.com> * python/py-varobj.c (py_varobj_iter_next): Return NULL if gdb_python_initialized is false. Move some code from varobj.c. * varobj-iter.h (struct varobj_item): Moved from varobj.c. * varobj.c: Move "varobj-iter.h" inclusion earlier. (struct varobj_item): Moved to varobj-iter.h". (varobj_clear_saved_item): New function. (update_dynamic_varobj_children): Move python-related code to py-varobj.c. (free_variable): Call varobj_clear_saved_item and varobj_iter_delete.
This commit is contained in:
parent
e525021603
commit
827f100cee
4 changed files with 70 additions and 53 deletions
|
@ -54,6 +54,12 @@ py_varobj_iter_next (struct varobj_iter *self)
|
|||
struct py_varobj_iter *t = (struct py_varobj_iter *) self;
|
||||
struct cleanup *back_to;
|
||||
PyObject *item;
|
||||
PyObject *py_v;
|
||||
varobj_item *vitem;
|
||||
const char *name = NULL;
|
||||
|
||||
if (!gdb_python_initialized)
|
||||
return NULL;
|
||||
|
||||
back_to = varobj_ensure_python_env (self->var);
|
||||
|
||||
|
@ -101,9 +107,21 @@ py_varobj_iter_next (struct varobj_iter *self)
|
|||
}
|
||||
}
|
||||
|
||||
if (!PyArg_ParseTuple (item, "sO", &name, &py_v))
|
||||
{
|
||||
gdbpy_print_stack ();
|
||||
error (_("Invalid item from the child list"));
|
||||
}
|
||||
|
||||
vitem = xmalloc (sizeof *vitem);
|
||||
vitem->value = convert_value_from_python (py_v);
|
||||
if (vitem->value == NULL)
|
||||
gdbpy_print_stack ();
|
||||
vitem->name = xstrdup (name);
|
||||
|
||||
self->next_raw_index++;
|
||||
do_cleanups (back_to);
|
||||
return item;
|
||||
return vitem;
|
||||
}
|
||||
|
||||
/* The 'vtable' of pretty-printed python varobj iterators. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue