From e525021603958709381fc4dc296cc2586aaa5dd7 Mon Sep 17 00:00:00 2001 From: Yao Qi Date: Fri, 30 Aug 2013 09:44:46 +0800 Subject: Generalize varobj iterator This patch generalizes varobj iterator, in a python-independent way. Note varobj_item is still a typedef of PyObject, we can only focus on API changes, and leave the data type changes to the next patch. As a result, we include "varobj-iter.h" after the typedef of PyObject in varobj.c, but it is an intermediate state. Finally, varobj-iter.h is independent of PyObject. This change is helpful to move some python-related code out of varobj.c. V2: - Fix a missing cleanup. - Fix typos. - Use XNEW. - Check against NULL explicitly. - Update copyright year for new added files. V3: - Call PyGILState_Ensure before Py_XDECREF. - Use CPYCHECKER_STEALS_REFERENCE_TO_ARG. - Code indentation. V4: - use varobj_ensure_python_env instead of PyGILState_Ensure. gdb: 2014-06-12 Pedro Alves Yao Qi * Makefile.in (SUBDIR_PYTHON_OBS): Add "py-varobj.o". (SUBDIR_PYTHON_SRCS): Add "python/py-varobj.c". (HFILES_NO_SRCDIR): Add "varobj-iter.h". (py-varobj.o): New rule. * python/py-varobj.c: New file. * python/python-internal.h (py_varobj_get_iterator): Declare. * varobj-iter.h: New file. * varobj.c: Include "varobj-iter.h" (struct varobj) : Change its type from "PyObject *" to "struct varobj_iter *". : Likewise. [HAVE_PYTHON] (varobj_ensure_python_env): Make it extern. [HAVE_PYTHON] (varobj_get_iterator): New function. (update_dynamic_varobj_children) [HAVE_PYTHON]: Move python-specific code to python/py-varobj.c. (install_visualizer): Call varobj_iter_delete instead of Py_XDECREF. * varobj.h (varobj_ensure_python_env): Declare. --- gdb/python/python-internal.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gdb/python/python-internal.h') diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 0198e9d..b7298d9 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -568,4 +568,9 @@ int gdb_pymodule_addobject (PyObject *module, const char *name, PyObject *object) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION; +struct varobj_iter; +struct varobj; +struct varobj_iter *py_varobj_get_iterator (struct varobj *var, + PyObject *printer); + #endif /* GDB_PYTHON_INTERNAL_H */ -- cgit v1.1