aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2016-11-08 20:14:32 -0700
committerTom Tromey <tom@tromey.com>2017-01-10 19:13:51 -0700
commit788f258604773ccbe9ccba71f9b1725930324275 (patch)
treedc2d84ba4f13ce91c861a4b144c3d76a9456d9c2
parent6cd67beaae58c9e870b79feea3cf74ffdf7a9b33 (diff)
downloadgdb-788f258604773ccbe9ccba71f9b1725930324275.zip
gdb-788f258604773ccbe9ccba71f9b1725930324275.tar.gz
gdb-788f258604773ccbe9ccba71f9b1725930324275.tar.bz2
Use gdbpy_enter_varobj in py-varobj.c
This converts the remaining functions in py-varobj.c to use gdbpy_enter_varobj. 2017-01-10 Tom Tromey <tom@tromey.com> * python/py-varobj.c (py_varobj_iter_dtor, py_varobj_iter_next): Use gdbpy_enter_varobj.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/python/py-varobj.c16
2 files changed, 10 insertions, 11 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6bca72d..9f19ede 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2017-01-10 Tom Tromey <tom@tromey.com>
+ * python/py-varobj.c (py_varobj_iter_dtor, py_varobj_iter_next):
+ Use gdbpy_enter_varobj.
+
+2017-01-10 Tom Tromey <tom@tromey.com>
+
* varobj.c (gdbpy_enter_varobj): New constructor.
* python/python-internal.h (gdbpy_enter_varobj): New class.
* python/py-varobj.c (py_varobj_get_iterator): Use
diff --git a/gdb/python/py-varobj.c b/gdb/python/py-varobj.c
index ffdfa30..bac226f 100644
--- a/gdb/python/py-varobj.c
+++ b/gdb/python/py-varobj.c
@@ -39,11 +39,8 @@ static void
py_varobj_iter_dtor (struct varobj_iter *self)
{
struct py_varobj_iter *dis = (struct py_varobj_iter *) self;
- struct cleanup *back_to = varobj_ensure_python_env (self->var);
-
+ gdbpy_enter_varobj enter_py (self->var);
Py_XDECREF (dis->iter);
-
- do_cleanups (back_to);
}
/* Implementation of the 'next' method of pretty-printed varobj
@@ -53,8 +50,6 @@ static varobj_item *
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;
@@ -62,9 +57,9 @@ py_varobj_iter_next (struct varobj_iter *self)
if (!gdb_python_initialized)
return NULL;
- back_to = varobj_ensure_python_env (self->var);
+ gdbpy_enter_varobj enter_py (self->var);
- item = PyIter_Next (t->iter);
+ gdbpy_ref item (PyIter_Next (t->iter));
if (item == NULL)
{
@@ -92,7 +87,7 @@ py_varobj_iter_next (struct varobj_iter *self)
name_str = xstrprintf ("<error at %d>",
self->next_raw_index++);
- item = Py_BuildValue ("(ss)", name_str, value_str.get ());
+ item.reset (Py_BuildValue ("(ss)", name_str, value_str.get ()));
xfree (name_str);
if (item == NULL)
{
@@ -108,7 +103,7 @@ py_varobj_iter_next (struct varobj_iter *self)
}
}
- if (!PyArg_ParseTuple (item, "sO", &name, &py_v))
+ if (!PyArg_ParseTuple (item.get (), "sO", &name, &py_v))
{
gdbpy_print_stack ();
error (_("Invalid item from the child list"));
@@ -121,7 +116,6 @@ py_varobj_iter_next (struct varobj_iter *self)
vitem->name = name;
self->next_raw_index++;
- do_cleanups (back_to);
return vitem;
}