* NEWS: Mention new "type" attribute of python gdb.Symbol objects.
authorDoug Evans <dje@google.com>
Fri, 12 Aug 2011 22:21:57 +0000 (22:21 +0000)
committerDoug Evans <dje@google.com>
Fri, 12 Aug 2011 22:21:57 +0000 (22:21 +0000)
* 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/ChangeLog
gdb/NEWS
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/python/py-symbol.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.python/py-symbol.exp

index 6443182f6d79f5d5517b1ca95ddb8fd0987b45fd..da7777e5434e0da9bcc36c0acc4902dddb03dfa7 100644 (file)
@@ -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
index da558508151ffe75972aa280410d8f2695ac094d..374b66288fc577290079acea907c6e9e47982bde 100644 (file)
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -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
index dbef2b11b20d20a6372cfe031d9dffc2ab4601e4..f9baf488cece0fd1ec97db3f91d8edad68548231 100644 (file)
@@ -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
index 9a0c8dbb11bf6b66a6fc936c5568f57d04e6eda6..3157ccb5bbe9b0bcd65b1d49abaad46ce8d7cb57 100644 (file)
@@ -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
index 046d78c76a94db83cde20312a6374b2905c2a628..8a8510e69793d8fa25cdc40971b4a8c59329627b 100644 (file)
@@ -65,6 +65,22 @@ sympy_str (PyObject *self)
   return result;
 }
 
+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)
 {
@@ -412,6 +428,8 @@ gdbpy_initialize_symbols (void)
 \f
 
 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,
index 6fa8048954ee768a93eb608b5541aacff569be3a..2870aa2cbb44fe44b6a8aedb34f4920179f95476 100644 (file)
@@ -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.
index 09d6bf027da7ed72c958545c6da81f84d82a81ef..76fceca8aed947ce185d324f4466b33efb436c78 100644 (file)
@@ -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
This page took 0.090603 seconds and 4 git commands to generate.