diff options
author | Christian Biesinger via gdb-patches <gdb-patches@sourceware.org> | 2019-05-23 16:37:29 -0500 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2019-06-04 09:46:06 -0600 |
commit | e1f2e1a2dadbaeffe0a8a6da7aab7effc6b046d2 (patch) | |
tree | c9b8498d0f320163e8edef62c5e2c5619028b27d /gdb/python | |
parent | a9d96ab97edabea31bed089bfd4caca80838e31c (diff) | |
download | binutils-e1f2e1a2dadbaeffe0a8a6da7aab7effc6b046d2.zip binutils-e1f2e1a2dadbaeffe0a8a6da7aab7effc6b046d2.tar.gz binutils-e1f2e1a2dadbaeffe0a8a6da7aab7effc6b046d2.tar.bz2 |
Add an objfile getter to gdb.Type
This allows users of the Python API to find the objfile where a type
was defined.
gdb/ChangeLog:
gdb/ChangeLog
2019-06-04 Christian Biesinger <cbiesinger@google.com>
Add objfile property to gdb.Type.
* gdb/NEWS: Mention Python API addition.
* gdb/python/py-type.c (typy_get_objfile): New method.
gdb/doc/ChangeLog
2019-06-04 Christian Biesinger <cbiesinger@google.com>
* gdb/doc/python.texi: Document new gdb.Type.objfile property.
gdb/testsuite/ChangeLog
2019-06-04 Christian Biesinger <cbiesinger@google.com>
* gdb/testsuite/gdb.python/py-type.exp: Test for new
gdb.Type.objfile property.
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/py-type.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 22cc658..7b99bea 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -413,6 +413,18 @@ typy_get_tag (PyObject *self, void *closure) return PyString_FromString (tagname); } +/* Return the type's objfile, or None. */ +static PyObject * +typy_get_objfile (PyObject *self, void *closure) +{ + struct type *type = ((type_object *) self)->type; + struct objfile *objfile = TYPE_OBJFILE (type); + + if (objfile == nullptr) + Py_RETURN_NONE; + return objfile_to_objfile_object (objfile).release (); +} + /* Return the type, stripped of typedefs. */ static PyObject * typy_strip_typedefs (PyObject *self, PyObject *args) @@ -1419,6 +1431,8 @@ static gdb_PyGetSetDef type_object_getset[] = "The size of this type, in bytes.", NULL }, { "tag", typy_get_tag, NULL, "The tag name for this type, or None.", NULL }, + { "objfile", typy_get_objfile, NULL, + "The objfile this type was defined in, or None.", NULL }, { NULL } }; |