From d096d8c11e4ab306d45e8dca811db2fa33e933a8 Mon Sep 17 00:00:00 2001 From: Doug Evans Date: Fri, 17 Oct 2014 10:57:26 -0700 Subject: Add gdb.Objfile.progspace attribute. gdb/ChangeLog: * NEWS: Mention new gdb.Objfile.progspace attribute. * python/py-objfile.c (objfpy_get_progspace): New function. (objfile_getset): New entry for "progspace". gdb/doc/ChangeLog: * python.texi (Objfiles In Python): Document new progspace attribute. gdb/testsuite/ChangeLog: * gdb.python/py-objfile.exp: Test progspace attribute. --- gdb/python/py-objfile.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'gdb/python/py-objfile.c') diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c index df29691..e868223 100644 --- a/gdb/python/py-objfile.c +++ b/gdb/python/py-objfile.c @@ -62,6 +62,24 @@ objfpy_get_filename (PyObject *self, void *closure) Py_RETURN_NONE; } +/* An Objfile method which returns the objfile's progspace, or None. */ + +static PyObject * +objfpy_get_progspace (PyObject *self, void *closure) +{ + objfile_object *obj = (objfile_object *) self; + + if (obj->objfile) + { + PyObject *pspace = pspace_to_pspace_object (obj->objfile->pspace); + + Py_XINCREF (pspace); + return pspace; + } + + Py_RETURN_NONE; +} + static void objfpy_dealloc (PyObject *o) { @@ -338,6 +356,8 @@ static PyGetSetDef objfile_getset[] = { { "filename", objfpy_get_filename, NULL, "The objfile's filename, or None.", NULL }, + { "progspace", objfpy_get_progspace, NULL, + "The objfile's progspace, or None.", NULL }, { "pretty_printers", objfpy_get_printers, objfpy_set_printers, "Pretty printers.", NULL }, { "frame_filters", objfpy_get_frame_filters, -- cgit v1.1