From 457e09f0601b9b3bbad55110af858bf25b02a69e Mon Sep 17 00:00:00 2001 From: Doug Evans Date: Fri, 12 Aug 2011 22:21:57 +0000 Subject: * NEWS: Mention new "type" attribute of python gdb.Symbol objects. * python/py-symbol.c (sympy_get_type): New function. (symbol_object_getset): Add "type". doc/ * gdb.texinfo (Symbols In Python): Document symbol.type. testsuite/ * gdb.python/py-symbol.exp: Add test for symbol.type. --- gdb/python/py-symbol.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'gdb/python') diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c index 046d78c..8a8510e 100644 --- a/gdb/python/py-symbol.c +++ b/gdb/python/py-symbol.c @@ -66,6 +66,22 @@ sympy_str (PyObject *self) } static PyObject * +sympy_get_type (PyObject *self, void *closure) +{ + struct symbol *symbol = NULL; + + SYMPY_REQUIRE_VALID (self, symbol); + + if (SYMBOL_TYPE (symbol) == NULL) + { + Py_INCREF (Py_None); + return Py_None; + } + + return type_to_type_object (SYMBOL_TYPE (symbol)); +} + +static PyObject * sympy_get_symtab (PyObject *self, void *closure) { struct symbol *symbol = NULL; @@ -412,6 +428,8 @@ gdbpy_initialize_symbols (void) static PyGetSetDef symbol_object_getset[] = { + { "type", sympy_get_type, NULL, + "Type of the symbol.", NULL }, { "symtab", sympy_get_symtab, NULL, "Symbol table in which the symbol appears.", NULL }, { "name", sympy_get_name, NULL, -- cgit v1.1