1 function compare_indices(i1, v1, i2, v2) {
2 c1 = strtonum(sprintf("%s", i1))
3 c2 = strtonum(sprintf("%s", i2))
8 function what_is(what_idx, type_idx, special, item, \
9 location, prev_location, prev_returned_size)
11 type_idx = array[what_idx]["type"]
12 special = array[what_idx]["special"]
15 switch (array[what_idx]["encoding"]) {
18 8*array[what_idx]["byte_size"] "_t")
21 printf("%s ", "uint" \
22 8*array[what_idx]["byte_size"] "_t")
24 default: # float, signed/unsigned char
25 printf("%s ", array[what_idx]["name"])
28 returned_size = array[what_idx]["byte_size"]
30 case "enumeration_type":
31 printf("%s ", "uint" 8*array[type_idx]["byte_size"] "_t")
32 returned_size = array[what_idx]["byte_size"]
35 printf("%s", "mpers_ptr_t ")
36 returned_size = array[what_idx]["byte_size"]
40 to_return = array[what_idx]["upper_bound"]
41 returned_size = array[what_idx]["upper_bound"] * returned_size
44 case "structure_type":
49 prev_returned_size = 0
51 if ("parent" in array[item] && \
52 array[item]["parent"] == what_idx) {
53 location = array[item]["location"]
54 loc_diff = location - prev_location - \
58 "unsigned char mpers_filler_" \
59 item "[" loc_diff "];\n")
61 prev_location = location
62 returned = what_is(item)
63 prev_returned_size = returned_size
64 printf("%s", array[item]["name"])
66 printf("%s", "[" returned "]")
71 returned_size = array[what_idx]["byte_size"]
72 loc_diff = returned_size - prev_location - prev_returned_size
74 printf("%s", "unsigned char mpers_end_filler_" \
75 item "[" loc_diff "];\n")
77 printf("%s", "} ATTRIBUTE_PACKED ")
82 if ("parent" in array[item] && \
83 array[item]["parent"] == what_idx) {
84 returned = what_is(item)
85 printf("%s", array[item]["name"])
87 printf("%s", "[" returned "]")
93 returned_size = array[what_idx]["byte_size"]
96 return what_is(type_idx)
99 return what_is(type_idx)
108 print "#include <inttypes.h>"
111 match($0, /([[:alnum:]]+)><([[:alnum:]]+)/, matches)
113 idx = "0x" matches[2]
114 array[idx]["idx"] = idx
117 array[idx]["parent"] = parent[level-1]
120 /^DW_AT_data_member_location/ {
121 match($0, /[[:digit:]]+/, temparray)
122 array[idx]["location"] = temparray[0]
125 match($0, /:[[:space:]]+([[:alpha:]_][[:alnum:]_[:space:]]*)/, \
127 array[idx]["name"] = temparray[1]
130 match($0, /[[:digit:]]+/, temparray)
131 array[idx]["byte_size"] = temparray[0]
134 match($0, /[[:digit:]]+/, temparray)
135 array[idx]["encoding"] = temparray[0]
138 match($0, /:[[:space:]]+<(0x[[:xdigit:]]*)>$/, temparray)
139 array[idx]["type"] = temparray[1]
141 /^DW_AT_upper_bound/ {
142 match($0, /[[:digit:]]+/, temparray)
143 array[parent[level-1]]["upper_bound"] = temparray[0] + 1
145 /^Abbrev Number:[^(]+\(DW_TAG_/ {
146 if (match($0, /typedef|union_type|structure_type|pointer_type\
147 |enumeration_type|array_type|base_type|member/, temparray)) {
148 array[idx]["special"] = temparray[0]
152 PROCINFO["sorted_in"] = "compare_indices"
153 for (item in array) {
154 if (array[item]["special"] == "pointer_type") {
155 print "typedef uint" \
156 8*array[item]["byte_size"] "_t mpers_ptr_t;"
160 for (item in array) {
161 if (array[item]["name"] == VAR_NAME) {
162 type=array[item]["type"]
164 what_is(array[item]["type"])
165 print ARCH_FLAG "_" array[type]["name"] ";"
166 print "#define MPERS_" \
167 ARCH_FLAG "_" array[type]["name"] " " \
168 ARCH_FLAG "_" array[type]["name"]