From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 88443 invoked by alias); 5 Feb 2016 12:18:33 -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 88428 invoked by uid 89); 5 Feb 2016 12:18:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=BAYES_00,KAM_STOCKGEN,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no version=3.3.2 spammy=sk:SYMBOL_, Hx-languages-length:1688, consumers, sentinel X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 05 Feb 2016 12:18:31 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 7B7C019CBB2; Fri, 5 Feb 2016 12:18:30 +0000 (UTC) Received: from [10.36.112.51] (ovpn-112-51.ams2.redhat.com [10.36.112.51]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u15CISVH010080; Fri, 5 Feb 2016 07:18:29 -0500 Subject: Re: [PATCH 5/7] py-symbol: export section name To: jeffm@suse.com, gdb-patches@sourceware.org References: <1454606973-31017-1-git-send-email-jeffm@suse.com> <1454606973-31017-6-git-send-email-jeffm@suse.com> From: Phil Muldoon Message-ID: <56B49314.8030608@redhat.com> Date: Fri, 05 Feb 2016 12:18:00 -0000 MIME-Version: 1.0 In-Reply-To: <1454606973-31017-6-git-send-email-jeffm@suse.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2016-02/txt/msg00140.txt.bz2 On 04/02/16 17:29, jeffm@suse.com wrote: > From: Jeff Mahoney > > Some consumers of the symbol API need to know in what section a symbol is > located. This exports the section name as a string. > --- > gdb/python/py-symbol.c | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c > index c7f0ff8..aad2edc 100644 > --- a/gdb/python/py-symbol.c > +++ b/gdb/python/py-symbol.c > @@ -238,6 +238,27 @@ sympy_is_valid (PyObject *self, PyObject *args) > Py_RETURN_TRUE; > } > > +static PyObject * > +sympy_section (PyObject *self, void *closure) > +{ > + struct symbol *symbol = NULL; > + PyObject *section_obj; > + struct obj_section *section; > + const char *name; > + > + SYMPY_REQUIRE_VALID (self, symbol); > + > + section = SYMBOL_OBJ_SECTION (symbol_objfile(symbol), symbol); > + if (section) { > + name = bfd_section_name (symbol_objfile(objfile)->obfd, > + section->the_bfd_section); > + if (name) > + return PyString_FromString (name); > + } > + > + Py_RETURN_NONE; > +} > + > /* Implementation of gdb.Symbol.value (self[, frame]) -> gdb.Value. Returns > the value of the symbol, or an error in various circumstances. */ > > @@ -590,6 +611,8 @@ to display demangled or mangled names.", NULL }, > "True if the symbol requires a frame for evaluation." }, > { "line", sympy_line, NULL, > "The source line number at which the symbol was defined." }, > + { "section", sympy_section, NULL, > + "Section of executable where symbol resides." }, > { NULL } /* Sentinel */ > }; > This looks fine, but it needs a documentation entry and tests. Cheers Phil