Next: , Previous: gdb.printing, Up: Python modules


23.2.4.2 gdb.types

This module provides a collection of utilities for working with gdb.Types objects.

get_basic_type (type)
Return type with const and volatile qualifiers stripped, and with typedefs and C++ references converted to the underlying type.

C++ example:

          typedef const int const_int;
          const_int foo (3);
          const_int& foo_ref (foo);
          int main () { return 0; }
     

Then in gdb:

          (gdb) start
          (gdb) python import gdb.types
          (gdb) python foo_ref = gdb.parse_and_eval("foo_ref")
          (gdb) python print gdb.types.get_basic_type(foo_ref.type)
          int
     

has_field (type, field)
Return True if type, assumed to be a type with fields (e.g., a structure or union), has field field.
make_enum_dict (enum_type)
Return a Python dictionary type produced from enum_type.
deep_items (type)
Returns a Python iterator similar to the standard gdb.Type.iteritems method, except that the iterator returned by deep_items will recursively traverse anonymous struct or union fields. For example:
          struct A
          {
              int a;
              union {
                  int b0;
                  int b1;
              };
          };
     

Then in gdb:

          (gdb) python import gdb.types
          (gdb) python struct_a = gdb.lookup_type("struct A")
          (gdb) python print struct_a.keys ()
          {['a', '']}
          (gdb) python print [k for k,v in gdb.types.deep_items(struct_a)]
          {['a', 'b0', 'b1']}