diff options
author | Doug Evans <dje@google.com> | 2014-12-08 08:50:48 -0800 |
---|---|---|
committer | Doug Evans <dje@google.com> | 2014-12-08 08:50:48 -0800 |
commit | a0be3e44c7f510df608e4a480dd05c173ce280ce (patch) | |
tree | 639476193625c02332874a058e10ca327fad7007 | |
parent | 137d04f77229e4e61098c5595a1edf70c3bc4d28 (diff) | |
download | gdb-a0be3e44c7f510df608e4a480dd05c173ce280ce.zip gdb-a0be3e44c7f510df608e4a480dd05c173ce280ce.tar.gz gdb-a0be3e44c7f510df608e4a480dd05c173ce280ce.tar.bz2 |
New "owner" attribute for gdb.Objfile.
gdb/ChangeLog:
* NEWS: Mention gdb.Objfile.owner.
* python/py-objfile.c (objfpy_get_owner): New function.
(objfile_getset): Add "owner".
gdb/doc/ChangeLog:
* python.texi (Objfiles In Python): Document Objfile.owner.
gdb/testsuite/ChangeLog:
* gdb.python/py-objfile.exp: Add tests for objfile.owner.
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/NEWS | 1 | ||||
-rw-r--r-- | gdb/doc/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/doc/python.texi | 8 | ||||
-rw-r--r-- | gdb/python/py-objfile.c | 22 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-objfile.exp | 6 |
7 files changed, 51 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 83e649e..8e4be25 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2014-12-08 Doug Evans <dje@google.com> + + * NEWS: Mention gdb.Objfile.owner. + * python/py-objfile.c (objfpy_get_owner): New function. + (objfile_getset): Add "owner". + 2014-12-05 Jan Kratochvil <jan.kratochvil@redhat.com> * symtab.c (lookup_symbol_in_objfile_symtabs): New declaration. @@ -21,6 +21,7 @@ ** New attribute 'producer' for gdb.Symtab objects. ** gdb.Objfile objects have a new attribute "progspace", which is the gdb.Progspace object of the containing program space. + ** gdb.Objfile objects have a new attribute "owner". ** gdb.Objfile objects have a new attribute "build_id", which is the build ID generated when the file was built. ** gdb.Objfile objects have a new method "add_separate_debug_file". diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 09318aa..14b2e53 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,7 @@ +2014-12-08 Doug Evans <dje@google.com> + + * python.texi (Objfiles In Python): Document Objfile.owner. + 2014-12-04 Doug Evans <dje@google.com> * python.texi (Objfiles In Python): Document diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi index f2e4a6e..efd258d 100644 --- a/gdb/doc/python.texi +++ b/gdb/doc/python.texi @@ -3495,6 +3495,14 @@ class. The file name of the objfile as a string. @end defvar +@defvar Objfile.owner +For separate debug info objfiles this is the corresponding @code{gdb.Objfile} +object that debug info is being provided for. +Otherwise this is @code{None}. +Separate debug info objfiles are added with the +@code{gdb.Objfile.add_separate_debug_file} method, described below. +@end defvar + @defvar Objfile.build_id The build ID of the objfile as a string. If the objfile does not have a build ID then the value is @code{None}. diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c index 292d310..51cf47c 100644 --- a/gdb/python/py-objfile.c +++ b/gdb/python/py-objfile.c @@ -80,6 +80,25 @@ objfpy_get_filename (PyObject *self, void *closure) Py_RETURN_NONE; } +/* If SELF is a separate debug-info file, return the "backlink" field. + Otherwise return None. */ + +static PyObject * +objfpy_get_owner (PyObject *self, void *closure) +{ + objfile_object *obj = (objfile_object *) self; + struct objfile *objfile = obj->objfile; + struct objfile *owner; + + OBJFPY_REQUIRE_VALID (obj); + + owner = objfile->separate_debug_objfile_backlink; + + if (owner != NULL) + return objfile_to_objfile_object (owner); + Py_RETURN_NONE; +} + /* An Objfile method which returns the objfile's build id, or None. */ static PyObject * @@ -442,6 +461,9 @@ static PyGetSetDef objfile_getset[] = "The __dict__ for this objfile.", &objfile_object_type }, { "filename", objfpy_get_filename, NULL, "The objfile's filename, or None.", NULL }, + { "owner", objfpy_get_owner, NULL, + "The objfile owner of separate debug info objfiles, or None.", + NULL }, { "build_id", objfpy_get_build_id, NULL, "The objfile's build id, or None.", NULL }, { "progspace", objfpy_get_progspace, NULL, diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index c389d7d..0e973f7 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2014-12-08 Doug Evans <dje@google.com> + + * gdb.python/py-objfile.exp: Add tests for objfile.owner. + 2014-12-05 Yao Qi <yao@codesourcery.com> * gdb.guile/scm-error.exp: Remove the third argument to diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp index 6c36f8e..f3a8a6c 100644 --- a/gdb/testsuite/gdb.python/py-objfile.exp +++ b/gdb/testsuite/gdb.python/py-objfile.exp @@ -76,6 +76,9 @@ if ![runto_main] { gdb_py_test_silent_cmd "python objfile = gdb.objfiles()\[0\]" \ "Get no-debug objfile file" 1 +gdb_test "python print (objfile.owner)" "None" \ + "Test owner of real objfile." + gdb_test "p main" "= {<text variable, no debug info>} $hex <main>" \ "print main without debug info" @@ -85,5 +88,8 @@ gdb_py_test_silent_cmd "python objfile.add_separate_debug_file(\"${binfile}\")" gdb_py_test_silent_cmd "python sep_objfile = gdb.objfiles()\[0\]" \ "Get separate debug info objfile" 1 +gdb_test "python print (sep_objfile.owner.filename)" "${testfile}2" \ + "Test owner of separate debug file" + gdb_test "p main" "= {int \\(\\)} $hex <main>" \ "print main with debug info" |