diff options
author | Doug Evans <dje@google.com> | 2011-08-12 22:21:57 +0000 |
---|---|---|
committer | Doug Evans <dje@google.com> | 2011-08-12 22:21:57 +0000 |
commit | 457e09f0601b9b3bbad55110af858bf25b02a69e (patch) | |
tree | 64b827bdb71bc4ea492d84638b378930b5413793 | |
parent | 505b88fb5d0725884d473d5a208e604bbda54c4f (diff) | |
download | gdb-457e09f0601b9b3bbad55110af858bf25b02a69e.zip gdb-457e09f0601b9b3bbad55110af858bf25b02a69e.tar.gz gdb-457e09f0601b9b3bbad55110af858bf25b02a69e.tar.bz2 |
* 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.
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/NEWS | 2 | ||||
-rw-r--r-- | gdb/doc/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/doc/gdb.texinfo | 6 | ||||
-rw-r--r-- | gdb/python/py-symbol.c | 18 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-symbol.exp | 5 |
7 files changed, 45 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6443182..da7777e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2011-08-12 Doug Evans <dje@google.com> + + * NEWS: Mention new "type" attribute of python gdb.Symbol objects. + * python/py-symbol.c (sympy_get_type): New function. + (symbol_object_getset): Add "type". + 2011-08-12 Pedro Alves <pedro@codesourcery.com> PR tui/13073 @@ -28,6 +28,8 @@ 'data-directory'/python/gdb/function are now automatically loaded on GDB start-up. + ** Symbols now provide the "type" attribute, the type of the symbol. + * libthread-db-search-path now supports two special values: $sdir and $pdir. $sdir specifies the default system locations of shared libraries. $pdir specifies the directory where the libpthread used by the application diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index dbef2b1..f9baf48 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,7 @@ +2011-08-12 Doug Evans <dje@google.com> + + * gdb.texinfo (Symbols In Python): Document symbol.type. + 2011-08-09 Phil Muldoon <pmuldoon@redhat.com> * gdb.texinfo (Python): Document command and function diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 9a0c8db..3157ccb 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -23198,6 +23198,12 @@ is not found. A @code{gdb.Symbol} object has the following attributes: @table @code +@defivar Symbol type +The type of the symbol or @code{None} if no type is recorded. +This attribute is represented as a @code{gdb.Type} object. +@xref{Types In Python}. This attribute is not writable. +@end defivar + @defivar Symbol symtab The symbol table in which the symbol appears. This attribute is represented as a @code{gdb.Symtab} object. @xref{Symbol Tables In 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, diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 6fa8048..2870aa2 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2011-08-12 Doug Evans <dje@google.com> + + * gdb.python/py-symbol.exp: Add test for symbol.type. + 2011-08-12 Ulrich Weigand <ulrich.weigand@linaro.org> * gdb.threads/pthreads.exp: Enable on non-native configurations. diff --git a/gdb/testsuite/gdb.python/py-symbol.exp b/gdb/testsuite/gdb.python/py-symbol.exp index 09d6bf0..76fceca 100644 --- a/gdb/testsuite/gdb.python/py-symbol.exp +++ b/gdb/testsuite/gdb.python/py-symbol.exp @@ -95,6 +95,11 @@ gdb_test "python print t\[0\].is_constant" "True" "Test t.is_constant" gdb_test "python print t\[0\].is_argument" "False" "Test t.is_argument" gdb_test "python print t\[0\].is_function" "False" "Test t.is_function" gdb_test "python print t\[0\].addr_class == gdb.SYMBOL_LOC_CONST" "True" "Test t.addr_class" + +# Test type attribute. +gdb_test "python print t\[0\].type" "enum tag" "Get type" + +# Test symtab attribute. gdb_test "python print t\[0\].symtab" "gdb.python/py-symbol.c.*" "Get symtab" # C++ tests |