]> granicus.if.org Git - strace/blobdiff - mpers.awk
netlink_sock_diag: print inet_diag_sockid.idiag_if as an interface index
[strace] / mpers.awk
index 73bf0b03a06250c5844a2361a400627199ed9071..fe5476313dcc30d3397e13f4418b95722585ea45 100644 (file)
--- a/mpers.awk
+++ b/mpers.awk
@@ -1,7 +1,8 @@
 #!/bin/gawk
 #
 # Copyright (c) 2015 Elvira Khabirova <lineprinter0@gmail.com>
-# Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org>
+# Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
+# Copyright (c) 2015-2017 The strace developers.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -67,6 +68,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)
 {
@@ -90,7 +99,6 @@ function what_is(what_idx, type_idx, special, item, \
                returned_size = array_get(what_idx, "byte_size")
                break
        case "enumeration_type":
-               type_idx = array_get(what_idx, "type")
                returned_size = array_get(what_idx, "byte_size")
                printf("uint%s_t ", 8 * returned_size)
                break
@@ -103,8 +111,8 @@ 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
+                       to_return = "[0]"
+               returned_size = array[what_idx]["count"] * returned_size
                return leave(what_idx, to_return)
                break
        case "structure_type":
@@ -126,11 +134,7 @@ function what_is(what_idx, type_idx, special, item, \
                                prev_location = location
                                returned = what_is(item)
                                prev_returned_size = returned_size
-                               printf("%s", array[item]["name"])
-                               if ("" != returned) {
-                                       printf("[%s]", returned)
-                               }
-                               print ";"
+                               printf("%s%s;\n", array[item]["name"], returned)
                        }
                }
                returned_size = array_get(what_idx, "byte_size")
@@ -147,11 +151,7 @@ function what_is(what_idx, type_idx, special, item, \
                        if ("parent" in array[item] && \
                                array_get(item, "parent") == what_idx) {
                                returned = what_is(item)
-                               printf("%s", array_get(item, "name"))
-                               if ("" != returned) {
-                                       printf("[%s]", returned)
-                               }
-                               print ";"
+                               printf("%s%s;\n", array[item]["name"], returned)
                        }
                }
                printf("} ")
@@ -173,6 +173,8 @@ function what_is(what_idx, type_idx, special, item, \
        return leave(what_idx, "")
 }
 BEGIN {
+       match(ARCH_FLAG, /[[:digit:]]+/, temparray)
+       default_pointer_size = temparray[0] / 8
        print "#include <inttypes.h>"
 }
 /^<[[:xdigit:]]+>/ {
@@ -181,9 +183,6 @@ BEGIN {
        idx = "0x" matches[2]
        array[idx]["idx"] = idx
        parent[level] = idx
-       if (level > 1) {
-               array[idx]["parent"] = parent[level-1]
-       }
 }
 /^DW_AT_data_member_location/ {
        if (!match($0, /\(DW_OP_plus_uconst:[[:space:]]+([[:digit:]]+)\)/, temparray))
@@ -209,12 +208,20 @@ 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)
+       update_upper_bound(parent[level - 1], temparray[0])
 }
 /^Abbrev Number:[^(]+\(DW_TAG_/ {
        if (match($0, /typedef|union_type|structure_type|pointer_type\
 |enumeration_type|array_type|base_type|member/, temparray)) {
                array[idx]["special"] = temparray[0]
+               if ("pointer_type" == temparray[0])
+                       array[idx]["byte_size"] = default_pointer_size
+               if (level > 1 && "member" == temparray[0])
+                       array[idx]["parent"] = parent[level-1]
        }
 }
 END {