Skip to content

Commit cc902e3

Browse files
committed
mpers.awk: add support for DWARF files generated by clang
* mpers.awk: Define default_pointer_size. Initialize byte_size for DW_TAG_pointer_type to default_pointer_size. Set parent for DW_TAG_member only. Handle DW_AT_count as an alternative to DW_AT_upper_bound.
1 parent 1ef7aa6 commit cc902e3

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

mpers.awk

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/gawk
22
#
33
# Copyright (c) 2015 Elvira Khabirova <[email protected]>
4-
# Copyright (c) 2015 Dmitry V. Levin <[email protected]>
4+
# Copyright (c) 2015-2016 Dmitry V. Levin <[email protected]>
55
# All rights reserved.
66
#
77
# Redistribution and use in source and binary forms, with or without
@@ -173,6 +173,8 @@ function what_is(what_idx, type_idx, special, item, \
173173
return leave(what_idx, "")
174174
}
175175
BEGIN {
176+
match(ARCH_FLAG, /[[:digit:]]+/, temparray)
177+
default_pointer_size = temparray[0] / 8
176178
print "#include <inttypes.h>"
177179
}
178180
/^<[[:xdigit:]]+>/ {
@@ -181,9 +183,6 @@ BEGIN {
181183
idx = "0x" matches[2]
182184
array[idx]["idx"] = idx
183185
parent[level] = idx
184-
if (level > 1) {
185-
array[idx]["parent"] = parent[level-1]
186-
}
187186
}
188187
/^DW_AT_data_member_location/ {
189188
if (!match($0, /\(DW_OP_plus_uconst:[[:space:]]+([[:digit:]]+)\)/, temparray))
@@ -211,10 +210,18 @@ BEGIN {
211210
match($0, /[[:digit:]]+/, temparray)
212211
array[parent[level-1]]["upper_bound"] = temparray[0] + 1
213212
}
213+
/^DW_AT_count/ {
214+
match($0, /[[:digit:]]+/, temparray)
215+
array[parent[level-1]]["upper_bound"] = temparray[0]
216+
}
214217
/^Abbrev Number:[^(]+\(DW_TAG_/ {
215218
if (match($0, /typedef|union_type|structure_type|pointer_type\
216219
|enumeration_type|array_type|base_type|member/, temparray)) {
217220
array[idx]["special"] = temparray[0]
221+
if ("pointer_type" == temparray[0])
222+
array[idx]["byte_size"] = default_pointer_size
223+
if (level > 1 && "member" == temparray[0])
224+
array[idx]["parent"] = parent[level-1]
218225
}
219226
}
220227
END {

0 commit comments

Comments
 (0)