This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 5/7] py-symbol: export section name
- From: jeffm at suse dot com
- To: gdb-patches at sourceware dot org
- Cc: Jeff Mahoney <jeffm at suse dot com>
- Date: Thu, 4 Feb 2016 12:29:31 -0500
- Subject: [PATCH 5/7] py-symbol: export section name
- Authentication-results: sourceware.org; auth=none
- References: <1454606973-31017-1-git-send-email-jeffm at suse dot com>
From: Jeff Mahoney <jeffm@suse.com>
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 */
};
--
2.1.4