1 function compare_indices(i1, v1, i2, v2) {
2 c1 = strtonum(sprintf("%s", i1))
3 c2 = strtonum(sprintf("%s", i2))
8 function array_get(array_idx, array_member, array_return)
10 array_return = array[array_idx][array_member]
11 if ("" == array_return) {
12 printf("%s: index [%s] without %s\n",
13 FILENAME, array_idx, array_member) > "/dev/stderr"
18 function what_is(what_idx, type_idx, special, item, \
19 location, prev_location, prev_returned_size)
21 special = array_get(what_idx, "special")
24 switch (array_get(what_idx, "encoding")) {
27 8 * array_get(what_idx, "byte_size") "_t")
30 printf("%s ", "uint" \
31 8 * array_get(what_idx, "byte_size") "_t")
33 default: # float, signed/unsigned char
34 printf("%s ", array_get(what_idx, "name"))
37 returned_size = array_get(what_idx, "byte_size")
39 case "enumeration_type":
40 type_idx = array_get(what_idx, "type")
41 returned_size = array_get(what_idx, "byte_size")
42 printf("%s ", "uint" 8 * returned_size "_t")
45 printf("%s", "mpers_ptr_t ")
46 returned_size = array_get(what_idx, "byte_size")
49 type_idx = array_get(what_idx, "type")
51 to_return = array[what_idx]["upper_bound"]
52 returned_size = to_return * returned_size
57 case "structure_type":
62 prev_returned_size = 0
64 if ("parent" in array[item] && \
65 array_get(item, "parent") == what_idx) {
66 location = array_get(item, "location")
67 loc_diff = location - prev_location - \
71 "unsigned char mpers_filler_" \
72 item "[" loc_diff "];\n")
74 prev_location = location
75 returned = what_is(item)
76 prev_returned_size = returned_size
77 printf("%s", array[item]["name"])
79 printf("[%s]", returned)
84 returned_size = array_get(what_idx, "byte_size")
85 loc_diff = returned_size - prev_location - prev_returned_size
87 printf("%s", "unsigned char mpers_end_filler_" \
88 item "[" loc_diff "];\n")
90 printf("%s", "} ATTRIBUTE_PACKED ")
95 if ("parent" in array[item] && \
96 array_get(item, "parent") == what_idx) {
97 returned = what_is(item)
98 printf("%s", array_get(item, "name"))
100 printf("[%s]", returned)
106 returned_size = array_get(what_idx, "byte_size")
109 type_idx = array_get(what_idx, "type")
110 return what_is(type_idx)
113 type_idx = array_get(what_idx, "type")
114 return what_is(type_idx)
117 type_idx = array_get(what_idx, "type")
124 print "#include <inttypes.h>"
127 match($0, /([[:alnum:]]+)><([[:alnum:]]+)/, matches)
129 idx = "0x" matches[2]
130 array[idx]["idx"] = idx
133 array[idx]["parent"] = parent[level-1]
136 /^DW_AT_data_member_location/ {
137 match($0, /[[:digit:]]+/, temparray)
138 array[idx]["location"] = temparray[0]
141 match($0, /:[[:space:]]+([[:alpha:]_][[:alnum:]_[:space:]]*)/, \
143 array[idx]["name"] = temparray[1]
146 match($0, /[[:digit:]]+/, temparray)
147 array[idx]["byte_size"] = temparray[0]
150 match($0, /[[:digit:]]+/, temparray)
151 array[idx]["encoding"] = temparray[0]
154 match($0, /:[[:space:]]+<(0x[[:xdigit:]]*)>$/, temparray)
155 array[idx]["type"] = temparray[1]
157 /^DW_AT_upper_bound/ {
158 match($0, /[[:digit:]]+/, temparray)
159 array[parent[level-1]]["upper_bound"] = temparray[0] + 1
161 /^Abbrev Number:[^(]+\(DW_TAG_/ {
162 if (match($0, /typedef|union_type|structure_type|pointer_type\
163 |enumeration_type|array_type|base_type|member/, temparray)) {
164 array[idx]["special"] = temparray[0]
168 PROCINFO["sorted_in"] = "compare_indices"
169 for (item in array) {
170 if (array[item]["special"] == "pointer_type") {
171 print "typedef uint" \
172 8 * array_get(item, "byte_size") "_t mpers_ptr_t;"
176 for (item in array) {
177 if (array[item]["name"] == VAR_NAME) {
178 type = array_get(item, "type")
181 name = array_get(type, "name")
182 print ARCH_FLAG "_" name ";"
183 print "#define MPERS_" \
184 ARCH_FLAG "_" name " " \