Next: gdb.prompt, Previous: gdb.printing, Up: Python modules
This module provides a collection of utilities for working with
gdb.Types objects.
get_basic_type (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)True if type, assumed to be a type with fields
(e.g., a structure or union), has field field.
make_enum_dict (enum_type)dictionary type produced from enum_type.
deep_items (type)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']}