aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorPaul Koning <pkoning@equallogic.com>2011-10-26 15:09:40 +0000
committerPaul Koning <pkoning@equallogic.com>2011-10-26 15:09:40 +0000
commit3eaf3fa2966a7174d42c8b94ad171e2de4665410 (patch)
treef93db4e1dd39155f4eb73843da9c9185fb284e81 /gdb/python
parentf6dd4781ef99e26500c98e3eb54bf01c7295915f (diff)
downloadgdb-3eaf3fa2966a7174d42c8b94ad171e2de4665410.zip
gdb-3eaf3fa2966a7174d42c8b94ad171e2de4665410.tar.gz
gdb-3eaf3fa2966a7174d42c8b94ad171e2de4665410.tar.bz2
* python/lib/gdb/types.py (deepitems): New function.
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/lib/gdb/types.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/gdb/python/lib/gdb/types.py b/gdb/python/lib/gdb/types.py
index 54fbe3c..9a9b245 100644
--- a/gdb/python/lib/gdb/types.py
+++ b/gdb/python/lib/gdb/types.py
@@ -89,3 +89,23 @@ def make_enum_dict(enum_type):
# The enum's value is stored in "bitpos".
enum_dict[field.name] = field.bitpos
return enum_dict
+
+
+def deepitems (type_):
+ """Return an iterator that recursively traverses anonymous fields.
+
+ Arguments:
+ type_: The type to traverse. It should be one of
+ gdb.TYPE_CODE_STRUCT or gdb.TYPE_CODE_UNION.
+
+ Returns:
+ an iterator similar to gdb.Type.iteritems(), i.e., it returns
+ pairs of key, value, but for any anonymous struct or union
+ field that field is traversed recursively, depth-first.
+ """
+ for k, v in type_.iteritems ():
+ if k:
+ yield k, v
+ else:
+ for i in deepitems (v.type):
+ yield i