From patchwork Thu Feb 4 17:29:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Mahoney X-Patchwork-Id: 10738 Received: (qmail 127835 invoked by alias); 4 Feb 2016 17:43:27 -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 127805 invoked by uid 89); 4 Feb 2016 17:43:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.4 required=5.0 tests=BAYES_00, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=no version=3.3.2 spammy=sk:SYMBOL_, Hx-languages-length:1482, consumers, sentinel X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Thu, 04 Feb 2016 17:43:23 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id DFE38AD88 for ; Thu, 4 Feb 2016 17:29:39 +0000 (UTC) Received: by starscream.home.jeffm.io (Postfix, from userid 1000) id 8131C8998B; Thu, 4 Feb 2016 12:29:34 -0500 (EST) From: jeffm@suse.com To: gdb-patches@sourceware.org Cc: Jeff Mahoney Subject: [PATCH 5/7] py-symbol: export section name Date: Thu, 4 Feb 2016 12:29:31 -0500 Message-Id: <1454606973-31017-6-git-send-email-jeffm@suse.com> In-Reply-To: <1454606973-31017-1-git-send-email-jeffm@suse.com> References: <1454606973-31017-1-git-send-email-jeffm@suse.com> X-IsSubscribed: yes 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 */ };