Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1135)

Side by Side Diff: gdb/python/lib/gdb/types.py

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gdb/python/lib/gdb/printing.py ('k') | gdb/python/py-auto-load.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Type utilities. 1 # Type utilities.
2 # Copyright (C) 2010-2012 Free Software Foundation, Inc. 2 # Copyright (C) 2010-2012 Free Software Foundation, Inc.
3 3
4 # This program is free software; you can redistribute it and/or modify 4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by 5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or 6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version. 7 # (at your option) any later version.
8 # 8 #
9 # This program is distributed in the hope that it will be useful, 9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 The dictionary of the enum. 79 The dictionary of the enum.
80 80
81 Raises: 81 Raises:
82 TypeError: The type is not an enum. 82 TypeError: The type is not an enum.
83 """ 83 """
84 84
85 if enum_type.code != gdb.TYPE_CODE_ENUM: 85 if enum_type.code != gdb.TYPE_CODE_ENUM:
86 raise TypeError("not an enum type") 86 raise TypeError("not an enum type")
87 enum_dict = {} 87 enum_dict = {}
88 for field in enum_type.fields(): 88 for field in enum_type.fields():
89 # The enum's value is stored in "bitpos". 89 # The enum's value is stored in "enumval".
90 enum_dict[field.name] = field.bitpos 90 enum_dict[field.name] = field.enumval
91 return enum_dict 91 return enum_dict
92 92
93 93
94 def deep_items (type_): 94 def deep_items (type_):
95 """Return an iterator that recursively traverses anonymous fields. 95 """Return an iterator that recursively traverses anonymous fields.
96 96
97 Arguments: 97 Arguments:
98 type_: The type to traverse. It should be one of 98 type_: The type to traverse. It should be one of
99 gdb.TYPE_CODE_STRUCT or gdb.TYPE_CODE_UNION. 99 gdb.TYPE_CODE_STRUCT or gdb.TYPE_CODE_UNION.
100 100
101 Returns: 101 Returns:
102 an iterator similar to gdb.Type.iteritems(), i.e., it returns 102 an iterator similar to gdb.Type.iteritems(), i.e., it returns
103 pairs of key, value, but for any anonymous struct or union 103 pairs of key, value, but for any anonymous struct or union
104 field that field is traversed recursively, depth-first. 104 field that field is traversed recursively, depth-first.
105 """ 105 """
106 for k, v in type_.iteritems (): 106 for k, v in type_.iteritems ():
107 if k: 107 if k:
108 yield k, v 108 yield k, v
109 else: 109 else:
110 for i in deep_items (v.type): 110 for i in deep_items (v.type):
111 yield i 111 yield i
OLDNEW
« no previous file with comments | « gdb/python/lib/gdb/printing.py ('k') | gdb/python/py-auto-load.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698