]> granicus.if.org Git - strace/commitdiff
xlat: extend syntax with #val_type directive
authorDmitry V. Levin <ldv@altlinux.org>
Fri, 29 Apr 2016 01:02:13 +0000 (01:02 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 29 Apr 2016 01:12:14 +0000 (01:12 +0000)
When #val_type directive is encountered, gen.sh starts using
XLAT_TYPE/XLAT_TYPE_PAIR macros instead of XLAT/XLAT_PAIR,
with #val_type's argument as a type.

For example, "#val_type uint64_t" means values of type uint64_t.

* xlat/gen.sh (gen_header, print_xlat, print_xlat_pair):
Add val_type support.

xlat/gen.sh

index ac3d46636f044653c4d3667f8ae33c6bdea09f71..7b074ef51e0560e9c9fe3fc5958cf9fff4cf1a26 100755 (executable)
@@ -64,7 +64,11 @@ print_xlat()
        local val
        val="$1"; shift
 
-       echo " XLAT(${val}),"
+       if [ -z "${val_type-}" ]; then
+               echo " XLAT(${val}),"
+       else
+               echo " XLAT_TYPE(${val_type}, ${val}),"
+       fi
 }
 
 print_xlat_pair()
@@ -73,7 +77,11 @@ print_xlat_pair()
        val="$1"; shift
        str="$1"; shift
 
-       echo " XLAT_PAIR(${val}, \"${str}\"),"
+       if [ -z "${val_type-}" ]; then
+               echo " XLAT_PAIR(${val}, \"${str}\"),"
+       else
+               echo " XLAT_TYPE_PAIR(${val_type}, ${val}, \"${str}\"),"
+       fi
 }
 
 cond_xlat()
@@ -134,6 +142,9 @@ gen_header()
                '#unterminated')
                        unterminated=1
                        ;;
+               '#val_type '*)
+                       # to be processed during 2nd pass
+                       ;;
                '#'*)
                        echo "${line}"
                        ;;
@@ -175,7 +186,7 @@ gen_header()
        fi
        echo "const struct xlat ${name}[] = {"
 
-       unconditional=
+       unconditional= val_type=
        # 2nd pass: output everything.
        while read line; do
                LC_COLLATE=C
@@ -186,6 +197,9 @@ gen_header()
                '#unterminated')
                        # processed during 1st pass
                        ;;
+               '#val_type '*)
+                       val_type="${line#\#val_type }"
+                       ;;
                [A-Z_]*)        # symbolic constants
                        if [ -n "${unconditional}" ]; then
                                print_xlat "${line}"