From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 81559 invoked by alias); 23 May 2019 19:34:12 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 81551 invoked by uid 89); 23 May 2019 19:34:12 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 23 May 2019 19:34:10 +0000 Received: from [172.16.0.120] (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 02A741E623; Thu, 23 May 2019 15:34:08 -0400 (EDT) Subject: Re: [PATCH] Add an objfile getter to gdb.Type To: Christian Biesinger , gdb-patches@sourceware.org References: <20190523183935.209380-1-cbiesinger@google.com> From: Simon Marchi Message-ID: Date: Thu, 23 May 2019 19:34:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190523183935.209380-1-cbiesinger@google.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2019-05/txt/msg00544.txt.bz2 Hi Christian, On 2019-05-23 2:39 p.m., Christian Biesinger via gdb-patches wrote: > diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi > index 98e52bb770..f769ad03a2 100644 > --- a/gdb/doc/python.texi > +++ b/gdb/doc/python.texi > @@ -1087,6 +1087,11 @@ languages have this concept. If this type has no tag name, then > @code{None} is returned. > @end defvar > > +@defvar Type.objfile > +The @code{gdb.Objfile} that this type was defined in, or @code{None} if > +there is no associated objfile. > +@end defvar > + > The following methods are provided: > > @defun Type.fields () > diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c > index 22cc658a8b..722960e032 100644 > --- a/gdb/python/py-type.c > +++ b/gdb/python/py-type.c > @@ -413,6 +413,20 @@ typy_get_tag (PyObject *self, void *closure) > return PyString_FromString (tagname); > } > > +/* Return the type's tag, or None. */ copy-pasto: "type's objfile" > +static PyObject * > +typy_get_objfile (PyObject *self, void *closure) > +{ > + struct type *type = ((type_object *) self)->type; > + struct objfile *objfile = nullptr; > + > + objfile = TYPE_OBJFILE(type); You can write it as struct objfile *objfile = objfile = TYPE_OBJFILE (type); directly. We would need a corresponding test though. It should be a relatively easy addition to testsuite/gdb.python/py-type.exp. See here for info about how to run just one test: https://sourceware.org/gdb/wiki/TestingGDB#Running_specific_tests Thanks! Simon