This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 4/4] python support for fetching separate debug files: is_separate_debug_file


This patch adds the ability for Python code to determine if an objfile
is a separate debug file: the new_objfile event gets called for them
too.

2014-11-20  Doug Evans  <dje@google.com>

	* NEWS: Mention gdb.Objfile.is_separate_debug_file.
	* python/py-objfile.c (objfpy_is_separate_debug_file): New function.
	(objfile_getset): Add "is_separate_debug_file".

	doc/
	* python.texi (Objfiles In Python): Document
	Objfile.is_separate_debug_file.

	testsuite/
	* gdb.python/py-objfile.exp: Add tests for
	objfile.is_separate_debug_file.

diff --git a/gdb/NEWS b/gdb/NEWS
index 6f2271e..ca33862 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -11,6 +11,9 @@
   ** 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 "is_separate_debug_file",
+     which is True if the objfile contains debug information for another
+     objfile.
   ** 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 attribute "have_debug_info", which is
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index b6beec7..79bc49b 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -3446,6 +3446,10 @@ class.
 The file name of the objfile as a string.
 @end defvar
 
+@defvar Objfile.is_separate_debug_file
+True if the objfile contains debug information for another objfile.
+@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 7a35652f..49c0604 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;
 }
 
+/* An Objfile method which returns a boolean indicating whether the objfile
+   is a separate debug file or not.  */
+
+static PyObject *
+objfpy_get_is_separate_debug_file (PyObject *self, void *closure)
+{
+  objfile_object *obj = (objfile_object *) self;
+  struct objfile *objfile = obj->objfile;
+  int is_separate_debug_file;
+
+  OBJFPY_REQUIRE_VALID (obj);
+
+  is_separate_debug_file = objfile->separate_debug_objfile_backlink != NULL;
+
+  if (is_separate_debug_file)
+    Py_RETURN_TRUE;
+  Py_RETURN_FALSE;
+}
+
 /* An Objfile method which returns the objfile's build id, or None.  */
 
 static PyObject *
@@ -468,6 +487,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 },
+  { "is_separate_debug_file", objfpy_get_is_separate_debug_file, NULL,
+    "True if the objfile contains debug information for another objfile.",
+    NULL },
   { "build_id", objfpy_get_build_id, NULL,
     "The objfile's build id, or None.", NULL },
   { "have_debug_info", objfpy_get_have_debug_info, NULL,
diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp
index b3de807..b66a6d6 100644
--- a/gdb/testsuite/gdb.python/py-objfile.exp
+++ b/gdb/testsuite/gdb.python/py-objfile.exp
@@ -79,6 +79,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.is_separate_debug_file)" "False" \
+    "Test is_separate_debug_info on real objfile."
+
 gdb_test "python print (objfile.have_debug_info)" "False" \
     "Get objfile have_debug_info"
 
@@ -91,6 +94,9 @@ 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.is_separate_debug_file)" "True" \
+    "Test is_separate_debug_info on separate debug file"
+
 gdb_test "python print (objfile.have_debug_info)" "True" \
     "Get have_debug_info on separate debug file"
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]