]> granicus.if.org Git - strace/commitdiff
Handle xlat verbosity in evdev bitset printing
authorEugene Syromyatnikov <evgsyr@gmail.com>
Fri, 19 Jul 2019 11:27:29 +0000 (13:27 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 24 Sep 2019 15:31:28 +0000 (15:31 +0000)
* defs.h (print_xint32_array_member, print_xint64_array_member): New
function declarations.
(print_xlong_array_member): New static inline function.
* util.c (print_xint32_array_member, print_xint64_array_member): New
functions.
* evdev.c (decode_bitset): Handle xlat verbosity option.
* tests/ioctl_evdev-Xabbrev.c: New file.
* tests/ioctl_evdev-Xraw.c: Likewise.
* tests/ioctl_evdev-Xverbose.c: Likewise.
* tests/ioctl_evdev-success-Xabbrev.c: Likewise.
* tests/ioctl_evdev-success-Xraw.c: Likewise.
* tests/ioctl_evdev-success-Xverbose.c: Likewise.
* tests/ioctl_evdev-success-v-Xabbrev.c: Likewise.
* tests/ioctl_evdev-success-v-Xraw.c: Likewise.
* tests/ioctl_evdev-success-v-Xverbose.c: Likewise.
* tests/ioctl_evdev-v-Xabbrev.c: Likewise.
* tests/ioctl_evdev-v-Xraw.c: Likewise.
* tests/ioctl_evdev-v-Xverbose.c: Likewise.
* tests/ioctl_evdev-success.c (test_evdev, print_getbit, main): Update
expected output.
* tests/ioctl_evdev.c (UNK_CMD): New macro.
(print_ffe_common, main): Update expected output.
* tests/Makefile.am (check_PROGRAMS): Add ioctl_evdev-success-Xabbrev,
ioctl_evdev-success-Xraw, ioctl_evdev-success-Xverbose,
ioctl_evdev-success-v-Xabbrev, ioctl_evdev-success-v-Xraw, and
ioctl_evdev-success-v-Xverbose.
* tests/gen_tests.in (ioctl_evdev-Xabbrev, ioctl_evdev-Xraw,
ioctl_evdev-Xverbose, ioctl_evdev-v-Xabbrev, ioctl_evdev-v-Xraw,
ioctl_evdev-v-Xverbose, ioctl_evdev-success-Xabbrev,
ioctl_evdev-success-Xraw, ioctl_evdev-success-Xverbose,
ioctl_evdev-success-v-Xabbrev, ioctl_evdev-success-v-Xraw,
ioctl_evdev-success-v-Xverbose tests): New entries.
(ioctl_evdev, ioctl_evdev-v): Add alignment option.
* tests/pure_executables.list: Add ioctl_evdev-Xabbrev,
ioctl_evdev-Xraw, ioctl_evdev-Xverbose, ioctl_evdev-v-Xabbrev,
ioctl_evdev-v-Xraw, ioctl_evdev-v-Xverbose.
* tests/.gitignore: Likewise.

21 files changed:
defs.h
evdev.c
tests/.gitignore
tests/Makefile.am
tests/gen_tests.in
tests/ioctl_evdev-Xabbrev.c [new file with mode: 0644]
tests/ioctl_evdev-Xraw.c [new file with mode: 0644]
tests/ioctl_evdev-Xverbose.c [new file with mode: 0644]
tests/ioctl_evdev-success-Xabbrev.c [new file with mode: 0644]
tests/ioctl_evdev-success-Xraw.c [new file with mode: 0644]
tests/ioctl_evdev-success-Xverbose.c [new file with mode: 0644]
tests/ioctl_evdev-success-v-Xabbrev.c [new file with mode: 0644]
tests/ioctl_evdev-success-v-Xraw.c [new file with mode: 0644]
tests/ioctl_evdev-success-v-Xverbose.c [new file with mode: 0644]
tests/ioctl_evdev-success.c
tests/ioctl_evdev-v-Xabbrev.c [new file with mode: 0644]
tests/ioctl_evdev-v-Xraw.c [new file with mode: 0644]
tests/ioctl_evdev-v-Xverbose.c [new file with mode: 0644]
tests/ioctl_evdev.c
tests/pure_executables.list
util.c

diff --git a/defs.h b/defs.h
index 9070986b12fd0dbfb1be88256a3aabed51c37315..7278bc36cc75bdee2775bd6758ada24aaede5e4f 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -844,6 +844,20 @@ extern bool print_uint32_array_member(struct tcb *, void *elem_buf,
                                      size_t elem_size, void *data);
 extern bool print_uint64_array_member(struct tcb *, void *elem_buf,
                                      size_t elem_size, void *data);
+extern bool print_xint32_array_member(struct tcb *, void *elem_buf,
+                                     size_t elem_size, void *data);
+extern bool print_xint64_array_member(struct tcb *, void *elem_buf,
+                                     size_t elem_size, void *data);
+
+static inline bool
+print_xlong_array_member(struct tcb *tcp, void *elem_buf, size_t elem_size,
+                        void *data)
+{
+       return dispatch_wordsize(print_xint64_array_member,
+                                print_xint32_array_member,
+                                tcp, elem_buf, elem_size, data);
+}
+
 
 typedef bool (*tfetch_mem_fn)(struct tcb *, kernel_ulong_t addr,
                              unsigned int size, void *dest);
diff --git a/evdev.c b/evdev.c
index 1baf3f12f55d338b5126d75cca9a4f42f55c8312..e2f10de377e2d2df6fb39e10b7568a1d54bd6ef7 100644 (file)
--- a/evdev.c
+++ b/evdev.c
@@ -169,27 +169,44 @@ decode_bitset(struct tcb *const tcp, const kernel_ulong_t arg,
        if (umove_or_printaddr(tcp, arg, &decoded_arg))
                return RVAL_IOCTL_DECODED;
 
-       tprints("[");
+       if (xlat_verbose(xlat_verbosity) != XLAT_STYLE_RAW) {
+               tprints("[");
 
-       int bit_displayed = 0;
-       int i = next_set_bit(decoded_arg, 0, size_bits);
-       if (i < 0) {
-               tprints(" 0 ");
-       } else {
-               printxval(decode_nr, i, dflt);
+               int bit_displayed = 0;
+               int i = next_set_bit(decoded_arg, 0, size_bits);
+               if (i < 0) {
+                       tprints(" 0 ");
+               } else {
+                       printxval(decode_nr, i, dflt);
 
-               while ((i = next_set_bit(decoded_arg, i + 1, size_bits)) > 0) {
-                       if (abbrev(tcp) && bit_displayed >= 3) {
-                               tprints(", ...");
-                               break;
+                       while ((i = next_set_bit(decoded_arg, i + 1,
+                                                size_bits)) > 0) {
+                               if (abbrev(tcp) && bit_displayed >= 3) {
+                                       tprints(", ...");
+                                       break;
+                               }
+                               tprints(", ");
+                               printxval(decode_nr, i, dflt);
+                               bit_displayed++;
                        }
-                       tprints(", ");
-                       printxval(decode_nr, i, dflt);
-                       bit_displayed++;
                }
+
+               tprints("]");
+       }
+
+       if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE)
+               tprints(" /* ");
+
+       if (xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV) {
+               uint64_t elem;
+
+               print_local_array(tcp, decoded_arg, size / current_wordsize,
+                                 &elem, current_wordsize,
+                                 print_xlong_array_member, NULL, 0);
        }
 
-       tprints("]");
+       if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE)
+               tprints(" */");
 
        return RVAL_IOCTL_DECODED;
 }
index 378f9e095c3f69903a2c75134d798722f29dba8a..f8374754c00cd298b574c43f38fbf6bb48533ab4 100644 (file)
@@ -171,7 +171,13 @@ ioctl_dm-v
 ioctl_evdev
 ioctl_evdev-success
 ioctl_evdev-success-v
+ioctl_evdev-Xabbrev
+ioctl_evdev-Xraw
+ioctl_evdev-Xverbose
 ioctl_evdev-v
+ioctl_evdev-v-Xabbrev
+ioctl_evdev-v-Xraw
+ioctl_evdev-v-Xverbose
 ioctl_inotify
 ioctl_kvm_run
 ioctl_kvm_run-v
index 444e82e3bd2df67bdbc57ccb43694d09d5e083bf..622f761c4fdd288184a154007ac05f006c57cc29 100644 (file)
@@ -106,7 +106,13 @@ check_PROGRAMS = $(PURE_EXECUTABLES) \
        int_0x80 \
        ioctl_dm-v \
        ioctl_evdev-success \
+       ioctl_evdev-success-Xabbrev \
+       ioctl_evdev-success-Xraw \
+       ioctl_evdev-success-Xverbose \
        ioctl_evdev-success-v \
+       ioctl_evdev-success-v-Xabbrev \
+       ioctl_evdev-success-v-Xraw \
+       ioctl_evdev-success-v-Xverbose \
        ioctl_loop-nv \
        ioctl_loop-v \
        ioctl_nsfs \
index ce263098000d3dd2e7b5263ec5d88153bb61e36c..9d913749b6bb8627a1603cdfa6a727c2490b89e8 100644 (file)
@@ -139,9 +139,21 @@ io_uring_setup     -a26 -y
 ioctl_block    +ioctl.test
 ioctl_dm       +ioctl.test -s9
 ioctl_dm-v     +ioctl.test -v -s9
-ioctl_evdev    +ioctl.test
-ioctl_evdev-v  +ioctl.test -v
+ioctl_evdev    +ioctl.test -a26
+ioctl_evdev-Xabbrev    +ioctl.test -a26 -Xabbrev
+ioctl_evdev-Xraw       +ioctl.test -a28 -Xraw
+ioctl_evdev-Xverbose   +ioctl.test -a41 -Xverbose
+ioctl_evdev-v  +ioctl.test -a26 -v
+ioctl_evdev-v-Xabbrev  +ioctl.test -a26 -v -Xabbrev
+ioctl_evdev-v-Xraw     +ioctl.test -a28 -v -Xraw
+ioctl_evdev-v-Xverbose +ioctl.test -a41 -v -Xverbose
+ioctl_evdev-success-Xabbrev    +ioctl_evdev-success.test -Xabbrev
+ioctl_evdev-success-Xraw       +ioctl_evdev-success.test -a27 -Xraw
+ioctl_evdev-success-Xverbose   +ioctl_evdev-success.test -a43 -Xverbose
 ioctl_evdev-success-v  +ioctl_evdev-success.test -a26 -v
+ioctl_evdev-success-v-Xabbrev  +ioctl_evdev-success.test -v -Xabbrev
+ioctl_evdev-success-v-Xraw     +ioctl_evdev-success.test -a27 -v -Xraw
+ioctl_evdev-success-v-Xverbose +ioctl_evdev-success.test -a43 -v -Xverbose
 ioctl_inotify  +ioctl.test
 ioctl_kvm_run  +ioctl.test -a36 -y
 ioctl_kvm_run-v        +ioctl.test -v -a36 -y
diff --git a/tests/ioctl_evdev-Xabbrev.c b/tests/ioctl_evdev-Xabbrev.c
new file mode 100644 (file)
index 0000000..ac474bf
--- /dev/null
@@ -0,0 +1,2 @@
+#define XLAT_ABBREV 1
+#include "ioctl_evdev.c"
diff --git a/tests/ioctl_evdev-Xraw.c b/tests/ioctl_evdev-Xraw.c
new file mode 100644 (file)
index 0000000..15f586f
--- /dev/null
@@ -0,0 +1,2 @@
+#define XLAT_RAW 1
+#include "ioctl_evdev.c"
diff --git a/tests/ioctl_evdev-Xverbose.c b/tests/ioctl_evdev-Xverbose.c
new file mode 100644 (file)
index 0000000..603c2f0
--- /dev/null
@@ -0,0 +1,2 @@
+#define XLAT_VERBOSE 1
+#include "ioctl_evdev.c"
diff --git a/tests/ioctl_evdev-success-Xabbrev.c b/tests/ioctl_evdev-success-Xabbrev.c
new file mode 100644 (file)
index 0000000..9f2416b
--- /dev/null
@@ -0,0 +1,2 @@
+#define XLAT_ABBREV 1
+#include "ioctl_evdev-success.c"
diff --git a/tests/ioctl_evdev-success-Xraw.c b/tests/ioctl_evdev-success-Xraw.c
new file mode 100644 (file)
index 0000000..097672a
--- /dev/null
@@ -0,0 +1,2 @@
+#define XLAT_RAW 1
+#include "ioctl_evdev-success.c"
diff --git a/tests/ioctl_evdev-success-Xverbose.c b/tests/ioctl_evdev-success-Xverbose.c
new file mode 100644 (file)
index 0000000..9ee67a0
--- /dev/null
@@ -0,0 +1,2 @@
+#define XLAT_VERBOSE 1
+#include "ioctl_evdev-success.c"
diff --git a/tests/ioctl_evdev-success-v-Xabbrev.c b/tests/ioctl_evdev-success-v-Xabbrev.c
new file mode 100644 (file)
index 0000000..566ad3e
--- /dev/null
@@ -0,0 +1,2 @@
+#define XLAT_ABBREV 1
+#include "ioctl_evdev-success-v.c"
diff --git a/tests/ioctl_evdev-success-v-Xraw.c b/tests/ioctl_evdev-success-v-Xraw.c
new file mode 100644 (file)
index 0000000..461bcd7
--- /dev/null
@@ -0,0 +1,2 @@
+#define XLAT_RAW 1
+#include "ioctl_evdev-success-v.c"
diff --git a/tests/ioctl_evdev-success-v-Xverbose.c b/tests/ioctl_evdev-success-v-Xverbose.c
new file mode 100644 (file)
index 0000000..1754320
--- /dev/null
@@ -0,0 +1,2 @@
+#define XLAT_VERBOSE 1
+#include "ioctl_evdev-success-v.c"
index 6d0cd98b76b8fcbc5c339d94982a3f789fb65957..22d64bde1325c9d78bf78d67e7e8c7748ade7236 100644 (file)
@@ -44,7 +44,7 @@ static void
 test_evdev(struct evdev_check *check, const void *arg)
 {
        long rc = invoke_test_syscall(check->cmd, check->arg_ptr);
-       printf("ioctl(-1, %s, ", check->cmd_str);
+       printf("ioctl(-1, %s, ", sprintxlat(check->cmd_str, check->cmd, NULL));
        if (check->print_arg)
                check->print_arg(rc, check->arg_ptr, arg);
        else
@@ -115,26 +115,52 @@ print_mtslots(long rc, const void *ptr, const void *arg)
 static void
 print_getbit(long rc, const void *ptr, const void *arg)
 {
-       const char * const *str = arg;
+       const char * const *str = arg + sizeof(char *);
+# if XLAT_RAW || XLAT_VERBOSE
+       const unsigned long *buf = ptr;
+       const unsigned long buf_size = (uintptr_t) (str[-1]);
+# endif
+
+
 
        if (rc <= 0) {
                printf("%p", ptr);
                return;
        }
 
+# if !XLAT_RAW
        printf("[");
        for (unsigned long i = 0; str[i]; i++) {
-# if ! VERBOSE
+#  if ! VERBOSE
                if (i >= 4) {
                        printf(", ...");
                        break;
                }
-# endif
+#  endif
                if (i)
                        printf(", ");
                printf("%s", str[i]);
        }
        printf("]");
+# endif /* !XLAT_RAW */
+
+# if XLAT_VERBOSE
+       printf(" /* ");
+# endif
+
+# if XLAT_RAW || XLAT_VERBOSE
+       printf("[");
+       const unsigned long cnt =
+               (MIN((unsigned long) rc, buf_size) + sizeof(long) - 1)
+               / sizeof(long);
+       for (unsigned long i = 0; i < cnt; i++)
+               printf("%s%#lx", i ? ", " : "", buf[i]);
+       printf("]");
+# endif
+
+# if XLAT_VERBOSE
+       printf(" */");
+# endif
 }
 
 int
@@ -159,8 +185,8 @@ main(int argc, char **argv)
 
        for (unsigned int i = 0; i < num_skip; i++) {
                long rc = ioctl(-1, EVIOCGID, NULL);
-               printf("ioctl(-1, EVIOCGID, NULL) = %s%s\n",
-                      sprintrc(rc),
+               printf("ioctl(-1, %s, NULL) = %s%s\n",
+                      XLAT_STR(EVIOCGID), sprintrc(rc),
                       rc == inject_retval ? " (INJECTED)" : "");
 
                if (rc != inject_retval)
@@ -187,7 +213,18 @@ main(int argc, char **argv)
        /* invalid flag */
        static const unsigned int invalid_mtslot[] = { -1, 1 };
        static const char * const invalid_mtslot_str[] = {
-               "0xffffffff /* ABS_MT_??? */", "1", NULL };
+               ""
+#  if !XLAT_RAW && !XLAT_VERBOSE
+               "0xffffffff"
+#  endif
+#  if !XLAT_VERBOSE
+               " /* "
+#  endif
+               "ABS_MT_???"
+#  if !XLAT_VERBOSE
+               " */"
+#  endif
+               , "1", NULL };
 # endif
 
        enum { ULONG_BIT = sizeof(unsigned long) * 8 };
@@ -197,21 +234,30 @@ main(int argc, char **argv)
                1 << EV_ABS | 1 << EV_MSC | 1 << EV_LED | 1 << EV_SND
                | 1 << EV_PWR };
        static const char * const ev_more_str_2[] = {
-               "EV_ABS", "EV_MSC", NULL };
+               (char *) (uintptr_t) 4,
+               XLAT_KNOWN(0x3, "EV_ABS"), XLAT_KNOWN(0x4, "EV_MSC"), NULL };
        static const char * const ev_more_str_3[] = {
-               "EV_ABS", "EV_MSC", "EV_LED", "EV_SND", "EV_PWR", NULL };
+               (char *) (uintptr_t) 4,
+               XLAT_KNOWN(0x3, "EV_ABS"), XLAT_KNOWN(0x4, "EV_MSC"),
+               XLAT_KNOWN(0x11, "EV_LED"), XLAT_KNOWN(0x12, "EV_SND"),
+               XLAT_KNOWN(0x16, "EV_PWR"), NULL };
 
        /* set less than 4 bits */
        static const unsigned long ev_less[NUM_WORDS] = {
                1 << EV_ABS | 1 << EV_MSC | 1 << EV_LED };
        static const char * const ev_less_str_2[] = {
-               "EV_ABS", "EV_MSC", NULL };
+               (char *) (uintptr_t) 4,
+               XLAT_KNOWN(0x3, "EV_ABS"), XLAT_KNOWN(0x4, "EV_MSC"), NULL };
        static const char * const ev_less_str_3[] = {
-               "EV_ABS", "EV_MSC", "EV_LED", NULL };
+               (char *) (uintptr_t) 4,
+               XLAT_KNOWN(0x3, "EV_ABS"), XLAT_KNOWN(0x4, "EV_MSC"),
+               XLAT_KNOWN(0x11, "EV_LED"), NULL };
 
        /* set zero bit */
        static const unsigned long ev_zero[NUM_WORDS] = { 0x0 };
-       static const char * const ev_zero_str[] = { " 0 ", NULL };
+       static const char * const ev_zero_str[] = {
+               (char *) (uintptr_t) 1,
+               " 0 ", NULL };
 
        /* KEY_MAX is 0x2ff which is greater than retval * 8 */
        static const unsigned long key[NUM_WORDS] = {
@@ -219,9 +265,12 @@ main(int argc, char **argv)
                [ KEY_F12 / ULONG_BIT ] = 1 << (KEY_F12 % ULONG_BIT) };
 
        static const char * const key_str_8[] = {
-               "KEY_1", "KEY_2", NULL };
+               (char *) (uintptr_t) (NUM_WORDS * sizeof(long)),
+               XLAT_KNOWN(0x2, "KEY_1"), XLAT_KNOWN(0x3, "KEY_2"), NULL };
        static const char * const key_str_16[] = {
-               "KEY_1", "KEY_2", "KEY_F12", NULL };
+               (char *) (uintptr_t) (NUM_WORDS * sizeof(long)),
+               XLAT_KNOWN(0x2, "KEY_1"), XLAT_KNOWN(0x3, "KEY_2"),
+               XLAT_KNOWN(0x58, "KEY_F12"), NULL };
 
        assert(sizeof(ev_more) >= (unsigned long) inject_retval);
        assert(sizeof(ev_less) >= (unsigned long) inject_retval);
diff --git a/tests/ioctl_evdev-v-Xabbrev.c b/tests/ioctl_evdev-v-Xabbrev.c
new file mode 100644 (file)
index 0000000..b2ed15c
--- /dev/null
@@ -0,0 +1,2 @@
+#define XLAT_ABBREV 1
+#include "ioctl_evdev-v.c"
diff --git a/tests/ioctl_evdev-v-Xraw.c b/tests/ioctl_evdev-v-Xraw.c
new file mode 100644 (file)
index 0000000..c6f4e53
--- /dev/null
@@ -0,0 +1,2 @@
+#define XLAT_RAW 1
+#include "ioctl_evdev-v.c"
diff --git a/tests/ioctl_evdev-v-Xverbose.c b/tests/ioctl_evdev-v-Xverbose.c
new file mode 100644 (file)
index 0000000..f911277
--- /dev/null
@@ -0,0 +1,2 @@
+#define XLAT_VERBOSE 1
+#include "ioctl_evdev-v.c"
index 02be472c7c05dbbc1e71828d576aef1548543de0..3e7c8961d9df2d4e754314f5385534893b51a914 100644 (file)
 #  define ABS_MT_TOOL_Y 0x3d
 # endif
 
+# if XLAT_VERBOSE
+#  define UNK_CMD(val_, str_) val_
+# else
+#  define UNK_CMD(val_, str_) val_ " /* " str_ " */"
+# endif
+
 static const unsigned int magic = 0xdeadbeef;
 static const unsigned long lmagic = (unsigned long) 0xdeadbeefbadc0dedULL;
 
@@ -43,9 +49,11 @@ print_envelope(const struct ff_envelope *const e)
 static void
 print_ffe_common(const struct ff_effect *const ffe, const char *const type_str)
 {
-       printf("ioctl(-1, EVIOCSFF, {type=%s, id=%" PRIu16
+       printf("ioctl(-1, %s", XLAT_STR(EVIOCSFF));
+       printf(", {type=%s, id=%" PRIu16
               ", direction=%" PRIu16 ", ",
-              type_str, ffe->id, ffe->direction);
+              sprintxlat(type_str, ffe->type, NULL),
+              ffe->id, ffe->direction);
 # if VERBOSE
        printf("trigger={button=%hu, interval=%hu}"
               ", replay={length=%hu, delay=%hu}",
@@ -54,10 +62,11 @@ print_ffe_common(const struct ff_effect *const ffe, const char *const type_str)
 # endif /* VERBOSE */
 }
 
-# define TEST_NULL_ARG_EX(cmd, str)                                            \
+# define TEST_NULL_ARG_EX(cmd, str)                                    \
        do {                                                            \
                ioctl(-1, cmd, 0);                                      \
-               printf("ioctl(-1, %s, NULL) = -1 EBADF (%m)\n", str);   \
+               printf("ioctl(-1, %s, NULL) = -1 EBADF (%m)\n",         \
+                      sprintxlat(str, cmd, NULL));                     \
        } while (0)
 
 # define TEST_NULL_ARG(cmd) TEST_NULL_ARG_EX(cmd, #cmd)
@@ -107,17 +116,23 @@ main(void)
        TEST_NULL_ARG(EVIOCGABS(ABS_X));
        TEST_NULL_ARG(EVIOCSABS(ABS_X));
 
-       TEST_NULL_ARG_EX(EVIOCGABS(0xe), "EVIOCGABS(0xe /* ABS_??? */)");
-       TEST_NULL_ARG_EX(EVIOCSABS(0xe), "EVIOCSABS(0xe /* ABS_??? */)");
+       TEST_NULL_ARG_EX(EVIOCGABS(0xe),
+                        "EVIOCGABS(" UNK_CMD("0xe", "ABS_???") ")");
+       TEST_NULL_ARG_EX(EVIOCSABS(0xe),
+                        "EVIOCSABS(" UNK_CMD("0xe", "ABS_???") ")");
 
        TEST_NULL_ARG(EVIOCGABS(ABS_MT_TOOL_Y));
        TEST_NULL_ARG(EVIOCSABS(ABS_MT_TOOL_Y));
 
-       TEST_NULL_ARG_EX(EVIOCGABS(0x3e), "EVIOCGABS(0x3e /* ABS_??? */)");
-       TEST_NULL_ARG_EX(EVIOCSABS(0x3e), "EVIOCSABS(0x3e /* ABS_??? */)");
+       TEST_NULL_ARG_EX(EVIOCGABS(0x3e),
+                        "EVIOCGABS(" UNK_CMD("0x3e", "ABS_???") ")");
+       TEST_NULL_ARG_EX(EVIOCSABS(0x3e),
+                        "EVIOCSABS(" UNK_CMD("0x3e", "ABS_???") ")");
 
-       TEST_NULL_ARG_EX(EVIOCGABS(0x3f), "EVIOCGABS(0x3f /* ABS_??? */)");
-       TEST_NULL_ARG_EX(EVIOCSABS(0x3f), "EVIOCSABS(0x3f /* ABS_??? */)");
+       TEST_NULL_ARG_EX(EVIOCGABS(0x3f),
+                        "EVIOCGABS(" UNK_CMD("0x3f", "ABS_???") ")");
+       TEST_NULL_ARG_EX(EVIOCSABS(0x3f),
+                        "EVIOCSABS(" UNK_CMD("0x3f", "ABS_???") ")");
 
        TEST_NULL_ARG(EVIOCGBIT(0, 0));
        TEST_NULL_ARG(EVIOCGBIT(EV_KEY, 1));
@@ -132,25 +147,36 @@ main(void)
        TEST_NULL_ARG(EVIOCGBIT(EV_PWR, 10));
        TEST_NULL_ARG(EVIOCGBIT(EV_FF_STATUS, 11));
 
-       TEST_NULL_ARG_EX(EVIOCGBIT(0x6, 12), "EVIOCGBIT(0x6 /* EV_??? */, 12)");
+       TEST_NULL_ARG_EX(EVIOCGBIT(0x6, 12),
+                        "EVIOCGBIT(" UNK_CMD("0x6", "EV_???") ", 12)");
        TEST_NULL_ARG_EX(EVIOCGBIT(0x18, 13),
-                        "EVIOCGBIT(0x18 /* EV_??? */, 13)");
+                        "EVIOCGBIT(" UNK_CMD("0x18", "EV_???") ", 13)");
        TEST_NULL_ARG_EX(EVIOCGBIT(0x1f, 14),
-                        "EVIOCGBIT(0x1f /* EV_??? */, 14)");
+                        "EVIOCGBIT(" UNK_CMD("0x1f", "EV_???") ", 14)");
 
        ioctl(-1, EVIOCGBIT(EV_MAX, 42), 0);
-       printf("ioctl(-1, EVIOCGBIT(%#x /* EV_??? */, 42), NULL)"
-              " = -1 EBADF (%m)\n", EV_MAX);
+       printf("ioctl(-1, ");
+# if XLAT_RAW
+       printf("%#x", EVIOCGBIT(EV_MAX, 42));
+# elif XLAT_VERBOSE
+       printf("%#x /* EVIOCGBIT(%#x, 42) */", EVIOCGBIT(EV_MAX, 42), EV_MAX);
+# else
+       printf("EVIOCGBIT(%#x /* EV_??? */, 42)", EV_MAX);
+# endif
+       printf(", NULL) = -1 EBADF (%m)\n");
 
        ioctl(-1, EVIOCRMFF, lmagic);
-       printf("ioctl(-1, EVIOCRMFF, %d) = -1 EBADF (%m)\n", (int) lmagic);
+       printf("ioctl(-1, %s, %d) = -1 EBADF (%m)\n",
+              XLAT_STR(EVIOCRMFF), (int) lmagic);
 
        ioctl(-1, EVIOCGRAB, lmagic);
-       printf("ioctl(-1, EVIOCGRAB, %lu) = -1 EBADF (%m)\n", lmagic);
+       printf("ioctl(-1, %s, %lu) = -1 EBADF (%m)\n",
+              XLAT_STR(EVIOCGRAB), lmagic);
 
 # ifdef EVIOCREVOKE
        ioctl(-1, EVIOCREVOKE, lmagic);
-       printf("ioctl(-1, EVIOCREVOKE, %lu) = -1 EBADF (%m)\n", lmagic);
+       printf("ioctl(-1, %s, %lu) = -1 EBADF (%m)\n",
+              XLAT_STR(EVIOCREVOKE), lmagic);
 # endif
 
        const unsigned int size = get_page_size();
@@ -162,7 +188,8 @@ main(void)
 
 # ifdef EVIOCSCLOCKID
        ioctl(-1, EVIOCSCLOCKID, val_int);
-       printf("ioctl(-1, EVIOCSCLOCKID, [%u]) = -1 EBADF (%m)\n", *val_int);
+       printf("ioctl(-1, %s, [%u]) = -1 EBADF (%m)\n",
+              XLAT_STR(EVIOCSCLOCKID), *val_int);
 # endif
 
        int *pair_int = tail_alloc(sizeof(*pair_int) * 2);
@@ -171,14 +198,15 @@ main(void)
 
 # ifdef EVIOSGREP
        ioctl(-1, EVIOCSREP, pair_int);
-       printf("ioctl(-1, EVIOCSREP, [%u, %u]) = -1 EBADF (%m)\n",
-              pair_int[0], pair_int[1]);
+       printf("ioctl(-1, %s, [%u, %u]) = -1 EBADF (%m)\n",
+              XLAT_STR(EVIOCSREP), pair_int[0], pair_int[1]);
 # endif
 
        pair_int[1] = 1;
        ioctl(-1, EVIOCSKEYCODE, pair_int);
-       printf("ioctl(-1, EVIOCSKEYCODE, [%u, %s]) = -1 EBADF (%m)\n",
-              pair_int[0], "KEY_ESC");
+       printf("ioctl(-1, %s, [%u, %s]) = -1 EBADF (%m)\n",
+              XLAT_STR(EVIOCSKEYCODE), pair_int[0],
+              XLAT_KNOWN(0x1, "KEY_ESC"));
 
 # ifdef EVIOCSKEYCODE_V2
        TAIL_ALLOC_OBJECT_CONST_PTR(struct input_keymap_entry, ike);
@@ -186,11 +214,11 @@ main(void)
        ike->keycode = 2;
 
        ioctl(-1, EVIOCSKEYCODE_V2, ike);
-       printf("ioctl(-1, EVIOCSKEYCODE_V2, {flags=%" PRIu8
-              ", len=%" PRIu8 ", ", ike->flags, ike->len);
+       printf("ioctl(-1, %s, {flags=%" PRIu8 ", len=%" PRIu8 ", ",
+              XLAT_STR(EVIOCSKEYCODE_V2), ike->flags, ike->len);
 #  if VERBOSE
        printf("index=%" PRIu16 ", keycode=%s, scancode=[",
-              ike->index, "KEY_1");
+              ike->index, XLAT_STR(KEY_1));
        unsigned int i;
        for (i = 0; i < ARRAY_SIZE(ike->scancode); ++i) {
                if (i > 0)
@@ -256,26 +284,37 @@ main(void)
 
        ffe->type = 0xff;
        ioctl(-1, EVIOCSFF, ffe);
-       print_ffe_common(ffe, "0xff /* FF_??? */");
+       print_ffe_common(ffe,
+#  if !XLAT_RAW && !XLAT_VERBOSE
+               "0xff"
+#  endif
+#  if !XLAT_VERBOSE
+               " /* "
+#  endif
+               "FF_???"
+#  if !XLAT_VERBOSE
+               " */"
+#  endif
+               );
        errno = EBADF;
        printf("}) = -1 EBADF (%m)\n");
 # endif
 
        ioctl(-1, _IOC(_IOC_READ, 0x45, 0x1, 0xff), lmagic);
        printf("ioctl(-1, %s, %#lx) = -1 EBADF (%m)\n",
-              "_IOC(_IOC_READ, 0x45, 0x1, 0xff)", lmagic);
+              XLAT_STR(_IOC(_IOC_READ, 0x45, 0x1, 0xff)), lmagic);
 
        ioctl(-1, _IOC(_IOC_WRITE, 0x45, 0x1, 0xff), lmagic);
        printf("ioctl(-1, %s, %#lx) = -1 EBADF (%m)\n",
-              "_IOC(_IOC_WRITE, 0x45, 0x1, 0xff)", lmagic);
+              XLAT_STR(_IOC(_IOC_WRITE, 0x45, 0x1, 0xff)), lmagic);
 
        ioctl(-1, _IOC(_IOC_READ|_IOC_WRITE, 0x45, 0xfe, 0xff), lmagic);
        printf("ioctl(-1, %s, %#lx) = -1 EBADF (%m)\n",
-              "_IOC(_IOC_READ|_IOC_WRITE, 0x45, 0xfe, 0xff)", lmagic);
+              XLAT_STR(_IOC(_IOC_READ|_IOC_WRITE, 0x45, 0xfe, 0xff)), lmagic);
 
        ioctl(-1, _IOC(_IOC_READ|_IOC_WRITE, 0x45, 0, 0), lmagic);
        printf("ioctl(-1, %s, %#lx) = -1 EBADF (%m)\n",
-              "_IOC(_IOC_READ|_IOC_WRITE, 0x45, 0, 0)", lmagic);
+              XLAT_STR(_IOC(_IOC_READ|_IOC_WRITE, 0x45, 0, 0)), lmagic);
 
        puts("+++ exited with 0 +++");
        return 0;
index 5ad5345589f8c55fd8536042c7eeb113c95507e6..0a61a8eb248240a66e2b350146677acecc50b4ab 100755 (executable)
@@ -141,7 +141,13 @@ ioctl
 ioctl_block
 ioctl_dm
 ioctl_evdev
+ioctl_evdev-Xabbrev
+ioctl_evdev-Xraw
+ioctl_evdev-Xverbose
 ioctl_evdev-v
+ioctl_evdev-v-Xabbrev
+ioctl_evdev-v-Xraw
+ioctl_evdev-v-Xverbose
 ioctl_inotify
 ioctl_kvm_run
 ioctl_kvm_run-v
diff --git a/util.c b/util.c
index d319428b0d808d19a77a75fa6b25760ae60d24ac..8d9e092bc4fa84f0a7f277713274dfa3bbdfca69 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1240,6 +1240,24 @@ print_uint64_array_member(struct tcb *tcp, void *elem_buf, size_t elem_size,
        return true;
 }
 
+bool
+print_xint32_array_member(struct tcb *tcp, void *elem_buf, size_t elem_size,
+                         void *data)
+{
+       tprintf("%#" PRIx32, *(uint32_t *) elem_buf);
+
+       return true;
+}
+
+bool
+print_xint64_array_member(struct tcb *tcp, void *elem_buf, size_t elem_size,
+                         void *data)
+{
+       tprintf("%#" PRIx64, *(uint64_t *) elem_buf);
+
+       return true;
+}
+
 /*
  * Iteratively fetch and print up to nmemb elements of elem_size size
  * from the array that starts at tracee's address start_addr.