]> granicus.if.org Git - strace/commitdiff
mpers.awk: add support for multidimensional arrays
authorEugene Syromyatnikov <evgsyr@gmail.com>
Tue, 4 Apr 2017 03:08:20 +0000 (05:08 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 4 Apr 2017 03:10:07 +0000 (03:10 +0000)
* 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.

mpers.awk
mpers_test.sh

index b9805421496ed8fe2a37fe267c371c0136db6daa..7b9b30bce0be7ca0ad9462936a8ea725a695fe1b 100644 (file)
--- a/mpers.awk
+++ b/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\
index 907460b8554eebf13c73d91ded12f8c5ba69e114..93f51917b0f0c975bfecbc22552c17dd8cbb5ded 100755 (executable)
@@ -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