]> granicus.if.org Git - strace/blobdiff - mpers.awk
tests: check decoding of accept4 syscall
[strace] / mpers.awk
index ca8f6fd74eb9c7893f3c8533591a19dc43874939..809acf8894bdd5d66f6a8326f447c15af2ece046 100644 (file)
--- a/mpers.awk
+++ b/mpers.awk
@@ -1,3 +1,31 @@
+#!/bin/gawk
+#
+# Copyright (c) 2015 Elvira Khabirova <lineprinter0@gmail.com>
+# Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote products
+#    derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
 function compare_indices(i1, v1, i2, v2) {
        c1 = strtonum(sprintf("%s", i1))
        c2 = strtonum(sprintf("%s", i2))
@@ -62,7 +90,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
@@ -145,6 +172,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:]]+>/ {
@@ -153,13 +182,11 @@ 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/ {
-       match($0, /[[:digit:]]+/, temparray)
-       array[idx]["location"] = temparray[0]
+       if (!match($0, /\(DW_OP_plus_uconst:[[:space:]]+([[:digit:]]+)\)/, temparray))
+               match($0, /([[:digit:]]+)/, temparray)
+       array[idx]["location"] = temparray[1]
 }
 /^DW_AT_name/ {
        match($0, /:[[:space:]]+([[:alpha:]_][[:alnum:]_[:space:]]*)/, \
@@ -182,10 +209,18 @@ BEGIN {
        match($0, /[[:digit:]]+/, temparray)
        array[parent[level-1]]["upper_bound"] = temparray[0] + 1
 }
+/^DW_AT_count/ {
+       match($0, /[[:digit:]]+/, temparray)
+       array[parent[level-1]]["upper_bound"] = 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 {