mpers.awk: add support for multidimensional arrays
* mpers.awk (update_upper_bound): New function, which maintains new "count" property for storing total element count and updates "upper_bound" property which now contains string with array dimensions. (/^DW_AT_upper_bound/, /^DW_AT_count/): Use it. (what_is) <case "array_type">: Use "count" property in order to calculate returned_size, do not embody returned string in square brackets. * mpers_test.sh: Add checks for multidimensional arrays.
This commit is contained in:
parent
a12c6a014b
commit
490b1caa52
18
mpers.awk
18
mpers.awk
@ -67,6 +67,14 @@ function leave(array_idx, to_return)
|
||||
delete called[array_idx]
|
||||
return to_return
|
||||
}
|
||||
function update_upper_bound(idx, val, count)
|
||||
{
|
||||
count = array[idx]["count"]
|
||||
if (count == "")
|
||||
count = 1
|
||||
array[idx]["count"] = count * val
|
||||
array[idx]["upper_bound"] = array[idx]["upper_bound"] "[" val "]"
|
||||
}
|
||||
function what_is(what_idx, type_idx, special, item, \
|
||||
location, prev_location, prev_returned_size)
|
||||
{
|
||||
@ -102,9 +110,9 @@ function what_is(what_idx, type_idx, special, item, \
|
||||
what_is(type_idx)
|
||||
to_return = array[what_idx]["upper_bound"]
|
||||
if ("" == to_return)
|
||||
to_return = 0
|
||||
returned_size = to_return * returned_size
|
||||
return leave(what_idx, "[" to_return "]")
|
||||
to_return = "[0]"
|
||||
returned_size = array[what_idx]["count"] * returned_size
|
||||
return leave(what_idx, to_return)
|
||||
break
|
||||
case "structure_type":
|
||||
print "struct {"
|
||||
@ -199,11 +207,11 @@ BEGIN {
|
||||
}
|
||||
/^DW_AT_upper_bound/ {
|
||||
match($0, /[[:digit:]]+/, temparray)
|
||||
array[parent[level-1]]["upper_bound"] = temparray[0] + 1
|
||||
update_upper_bound(parent[level - 1], temparray[0] + 1)
|
||||
}
|
||||
/^DW_AT_count/ {
|
||||
match($0, /[[:digit:]]+/, temparray)
|
||||
array[parent[level-1]]["upper_bound"] = temparray[0]
|
||||
update_upper_bound(parent[level - 1], temparray[0])
|
||||
}
|
||||
/^Abbrev Number:[^(]+\(DW_TAG_/ {
|
||||
if (match($0, /typedef|union_type|structure_type|pointer_type\
|
||||
|
@ -56,7 +56,7 @@ typedef struct {
|
||||
long long sll __attribute__((__aligned__(8)));
|
||||
unsigned long long ull;
|
||||
unsigned long ul;
|
||||
long asl[3];
|
||||
long asl[3][5][7];
|
||||
char f;
|
||||
/* unsigned char mpers_end_filler_4[7]; */
|
||||
} s;
|
||||
@ -68,11 +68,11 @@ typedef struct {
|
||||
unsigned long ul;
|
||||
int si;
|
||||
unsigned ui;
|
||||
short ss;
|
||||
unsigned short us;
|
||||
short ss[7][9];
|
||||
unsigned short us[4];
|
||||
char sc;
|
||||
unsigned char uc;
|
||||
} u[3];
|
||||
} u[3][2];
|
||||
short f[0];
|
||||
} sample_struct;
|
||||
#include MPERS_DEFS
|
||||
@ -99,7 +99,7 @@ unsigned char mpers_filler_3[6];
|
||||
int64_t sll;
|
||||
uint64_t ull;
|
||||
uint${size}_t ul;
|
||||
int${size}_t asl[3];
|
||||
int${size}_t asl[3][5][7];
|
||||
char f;
|
||||
unsigned char mpers_end_filler_4[7];
|
||||
} ATTRIBUTE_PACKED s;
|
||||
@ -111,11 +111,11 @@ int${size}_t sl;
|
||||
uint${size}_t ul;
|
||||
int32_t si;
|
||||
uint32_t ui;
|
||||
int16_t ss;
|
||||
uint16_t us;
|
||||
int16_t ss[7][9];
|
||||
uint16_t us[4];
|
||||
char sc;
|
||||
unsigned char uc;
|
||||
} u[3];
|
||||
} u[3][2];
|
||||
int16_t f[0];
|
||||
} ATTRIBUTE_PACKED ${mpers_name}_sample_struct;
|
||||
#define MPERS_${mpers_name}_sample_struct ${mpers_name}_sample_struct
|
||||
|
Loading…
x
Reference in New Issue
Block a user