From patchwork Thu Dec 4 20:56:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 4072 Received: (qmail 3087 invoked by alias); 4 Dec 2014 20:57:01 -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 3071 invoked by uid 89); 4 Dec 2014 20:57:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 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-ig0-f201.google.com Received: from mail-ig0-f201.google.com (HELO mail-ig0-f201.google.com) (209.85.213.201) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 04 Dec 2014 20:56:58 +0000 Received: by mail-ig0-f201.google.com with SMTP id h15so2090953igd.0 for ; Thu, 04 Dec 2014 12:56:56 -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=AR6mUxAPqpSGaGfoEKafxiDTEj1u6NEACbsTEU7GAFY=; b=A2WAQd8KegiJVE2fjdpqoo0MDJMmKwX+yOaHDj39yE3vIxMuQhP2PxGZAKVfoA6wrM DmhQSxNSl4W4R8Rtlf40LhquUOTkyO2X3YOkQ4aZLzMEgNY7j6NFo8jvf7InO3+6vs4n 3b2s63CIeOxuakGSwt24zoKOZJnFOei7vgw8fv3/zGfXc1VBMEoKM0YwKUJR9PgK3Oui ZoztOANK2a9WHUDL/zbj5dPSOboZ4O/Nl4B3eJtEByQ9LcGlNweovye03URqy9k2+Im+ UyBPrN+cKtKwi5joOjMqNVfkFO+sTSLuR60J6BLJk/WGblJPCDPxPk3zzUtfXA82AbGN pxCg== X-Gm-Message-State: ALoCoQmS+GNIFc+MFum3mS6bHHAbGdJ/pkfCvsQSq/byaDvZsY/cAmkT1TtooSAXPI22XTVnlXOD X-Received: by 10.42.118.75 with SMTP id w11mr15403891icq.5.1417726616425; Thu, 04 Dec 2014 12:56:56 -0800 (PST) Received: from corpmail-nozzle1-1.hot.corp.google.com ([100.108.1.104]) by gmr-mx.google.com with ESMTPS id t24si1180429yht.2.2014.12.04.12.56.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Dec 2014 12:56:56 -0800 (PST) Received: from ruffy.mtv.corp.google.com ([172.17.128.44]) by corpmail-nozzle1-1.hot.corp.google.com with ESMTPS id iJ9xSCcG.1; Thu, 04 Dec 2014 12:56:56 -0800 From: Doug Evans To: gdb-patches@sourceware.org, eliz@gnu.org Subject: [PATCH 4/4 v2] python support for fetching separate debug files: owner Date: Thu, 04 Dec 2014 12:56:55 -0800 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Hi. This patch is a replacement for https://sourceware.org/ml/gdb-patches/2014-11/msg00492.html That patch just added a boolean "is_separate_debug_file" attribute to gdb.Objfile. I wanted to keep things minimal/simple, but OTOH I can see a need for getting the objfile backlink field, and why have two attributes (is_separate_debug_file and owner) when one will do? Regression tested on amd64-linux. 2014-12-04 Doug Evans * NEWS: Mention gdb.Objfile.owner. * python/py-objfile.c (objfpy_get_owner): New function. (objfile_getset): Add "owner". doc/ * python.texi (Objfiles In Python): Document Objfile.owner. testsuite/ * gdb.python/py-objfile.exp: Add tests for objfile.owner. diff --git a/gdb/NEWS b/gdb/NEWS index c30cda2..6a2cb9b 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -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/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/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" "= {} $hex
" \ "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
" \ "print main with debug info"