Skip to content

Commit 108e184

Browse files
authored
Describing volatile C++ datatypes (#597)
1 parent 3181eed commit 108e184

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

elftools/dwarf/datatype_cpp.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
cpp_symbols = dict(
1313
pointer = "*",
1414
reference = "&",
15-
const = "const")
15+
const = "const",
16+
volatile = "volatile")
1617

1718
def describe_cpp_datatype(var_die):
1819
return str(parse_cpp_datatype(var_die))
@@ -36,8 +37,8 @@ def parse_cpp_datatype(var_die):
3637

3738
mods = []
3839
# Unlike readelf, dwarfdump doesn't chase typedefs
39-
while type_die.tag in ('DW_TAG_const_type', 'DW_TAG_pointer_type', 'DW_TAG_reference_type'):
40-
modifier = _strip_type_tag(type_die) # const/reference/pointer
40+
while type_die.tag in ('DW_TAG_const_type', 'DW_TAG_volatile_type', 'DW_TAG_pointer_type', 'DW_TAG_reference_type'):
41+
modifier = _strip_type_tag(type_die) # const/volatile/reference/pointer
4142
mods.insert(0, modifier)
4243
if not 'DW_AT_type' in type_die.attributes: # void* is encoded as a pointer to nothing
4344
t.name = t.tag = "void"
@@ -145,9 +146,9 @@ def __str__(self):
145146
mods = self.modifiers
146147

147148
parts = []
148-
# Initial const applies to the var ifself, other consts apply to the pointee
149-
if len(mods) and mods[0] == 'const':
150-
parts.append("const")
149+
# Initial const/volatile applies to the var ifself, other consts apply to the pointee
150+
if len(mods) and mods[0] in ('const', 'volatile'):
151+
parts.append(mods[0])
151152
mods = mods[1:]
152153

153154
# ref->const in the end, const goes in front
Binary file not shown.

0 commit comments

Comments
 (0)