Introduce gdbpy_enter_varobj and use it

This introduces gdbpy_enter_varobj, a subclass of gdbpy_enter; then
changes one function in py-varobj.c to use it.  gdbpy_enter_varobj
takes a varobj as an argument, similar to varobj_ensure_python_env.

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
	gdbpy_enter_varobj.
This commit is contained in:
Tom Tromey 2016-11-08 16:18:24 -07:00
parent 14b122bf1c
commit 6cd67beaae
4 changed files with 33 additions and 13 deletions

View file

@ -526,6 +526,18 @@ class gdbpy_enter
PyObject *m_error_type, *m_error_value, *m_error_traceback;
};
/* Like gdbpy_enter, but takes a varobj. This is a subclass just to
make constructor delegation a little nicer. */
class gdbpy_enter_varobj : public gdbpy_enter
{
public:
/* This is defined in varobj.c, where it can access varobj
internals. */
gdbpy_enter_varobj (const struct varobj *var);
};
struct cleanup *ensure_python_env (struct gdbarch *gdbarch,
const struct language_defn *language);