Add gdb.Objfile.progspace attribute.
authorDoug Evans <dje@google.com>
Fri, 17 Oct 2014 17:57:26 +0000 (10:57 -0700)
committerDoug Evans <dje@google.com>
Fri, 17 Oct 2014 17:57:26 +0000 (10:57 -0700)
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/ChangeLog
gdb/NEWS
gdb/doc/ChangeLog
gdb/doc/python.texi
gdb/python/py-objfile.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.python/py-objfile.exp

index f1a85deea167649d48881e33d7148e90e41e6d58..4122ad0dd5fdefff692e6bcd675fd089cf503ada 100644 (file)
@@ -1,3 +1,9 @@
+2014-10-17  Doug Evans  <dje@google.com>
+
+       * NEWS: Mention new gdb.Objfile.progspace attribute.
+       * python/py-objfile.c (objfpy_get_progspace): New function.
+       (objfile_getset): New entry for "progspace".
+
 2014-10-17  Pedro Alves  <palves@redhat.com>
 
        PR gdb/17471
index 5a2292621af7ee065bcce1bb8eb7dbb88c9cfb7d..76b44e83db432f3817bc1bcbb8161d7e741ebf2e 100644 (file)
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -9,6 +9,8 @@
 
   ** You can now access frame registers from Python scripts.
   ** 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.
 
 * New Python-based convenience functions:
 
index 432899b6da4ee5c34246c8aea787f57efa15c901..8c00c3233ff9b1c44431640e8dcee365f1c683d2 100644 (file)
@@ -1,3 +1,7 @@
+2014-10-17  Doug Evans  <dje@google.com>
+
+       * python.texi (Objfiles In Python): Document new progspace attribute.
+
 2014-10-17  Pedro Alves  <palves@redhat.com>
 
        * gdb.texinfo (Ada Tasks and Core Files): Delete mention of Tru64.
index 81ec11bc6a162b19205ba51d8e3511fe8e7d1569..84d66378da2940e8dabf820d434529cc9c26bc3e 100644 (file)
@@ -3392,6 +3392,11 @@ class.
 The file name of the objfile as a string.
 @end defvar
 
+@defvar Objfile.progspace
+The containing program space of the objfile as a @code{gdb.Progspace}
+object.  @xref{Progspaces In Python}.
+@end defvar
+
 @defvar Objfile.pretty_printers
 The @code{pretty_printers} attribute is a list of functions.  It is
 used to look up pretty-printers.  A @code{Value} is passed to each
index df296918d70edcd8fb6920496c3983310ee17331..e8682230882d10d33e5188b82c93dc1ceea9d4c0 100644 (file)
@@ -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,
index 6a1d42ec731adb19fe49025e55ca9577625be8c3..129cd7a113f0d5eb58eeb749176ea22012e3786e 100644 (file)
@@ -1,3 +1,7 @@
+2014-10-17  Doug Evans  <dje@google.com>
+
+       * gdb.python/py-objfile.exp: Test progspace attribute.
+
 2014-10-17  Luis Machado  <lgustavo@codesourcery.com>
 
        * gdb.guile/scm-breakpoint.exp: Do not assume any
index 1d2f55029354b8ff26d0c9aa23506330c6569241..87961703f0923b81c1fa8ab1305a0a60908cd4b1 100644 (file)
@@ -39,6 +39,8 @@ gdb_py_test_silent_cmd "python objfile = sym\[0\].symtab.objfile" \
 
 gdb_test "python print (objfile.filename)" ".*py-objfile.*" \
   "Get objfile file name"
+gdb_test "python print (objfile.progspace)" "<gdb\.Progspace object at .*>" \
+  "Get objfile program space"
 gdb_test "python print (objfile.is_valid())" "True" \
   "Get objfile validity"
 gdb_unload
This page took 0.047689 seconds and 4 git commands to generate.