From patchwork Thu Nov 20 21:26:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 3822 Received: (qmail 7161 invoked by alias); 20 Nov 2014 21:26:07 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 7060 invoked by uid 89); 20 Nov 2014 21:26:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail-pa0-f73.google.com Received: from mail-pa0-f73.google.com (HELO mail-pa0-f73.google.com) (209.85.220.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 20 Nov 2014 21:26:04 +0000 Received: by mail-pa0-f73.google.com with SMTP id lj1so547009pab.2 for ; Thu, 20 Nov 2014 13:26:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-type; bh=1zsZ8I2OyUKCpfCPpg4bjt0wiEHm+jGfJDa4gix29Rw=; b=XCc7zGNJtAR38ZtilhumSy+jIU4elNPJGUMOtWGE+uk9ypIAVNSfwSPChFEq0N6KJq ADEDmhAx1uAoLKjcIsxaoIdIcmxxhWLWn3nYSNQ8B3EnDArQGjwWo4BJk5Kxr5XSfJR6 X/MNMsle1E2MUxYVtSt+1eyxSvsKM//er1t31Q3CXFF7rzlB/ILidamBciidTBx8qPww EK85RbeN7Sdd8teEYPPKqSbzIioAU62hCvz8WvOqMvx5mFHZF43URXAk9knbapzJWKBe JF5C+dqYOO5uNP3lwU/E6rolTO1fUgFasodQdRcLLd0aqoWRqW1kOwJKDIRfjcRi73ZW 8PLg== X-Gm-Message-State: ALoCoQlBIsUqZoreUj2TL8C+DV8A++c89R++mm+tutvbnDKZufyjTqm/YP8aF70HlbfkCd/vk/94 X-Received: by 10.66.97.39 with SMTP id dx7mr579938pab.29.1416518762592; Thu, 20 Nov 2014 13:26:02 -0800 (PST) Received: from corpmail-nozzle1-1.hot.corp.google.com ([100.108.1.104]) by gmr-mx.google.com with ESMTPS id lu9si845415qcb.0.2014.11.20.13.26.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Nov 2014 13:26:02 -0800 (PST) Received: from ruffy.mtv.corp.google.com ([172.17.128.44]) by corpmail-nozzle1-1.hot.corp.google.com with ESMTPS id 7h1NH5Ka.1; Thu, 20 Nov 2014 13:26:02 -0800 From: Doug Evans To: gdb-patches@sourceware.org, eliz@gnu.org, palves@redhat.com, sergiodj@redhat.com Subject: [PATCH 4/4] python support for fetching separate debug files: is_separate_debug_file Date: Thu, 20 Nov 2014 13:26:01 -0800 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes 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 * 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"