Browse Source

Handle xlat verbosity in evdev bitset printing

* 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.
Eugene Syromyatnikov 3 months ago
parent
commit
d24458b299

+ 14
- 0
defs.h View File

@@ -844,6 +844,20 @@ extern bool print_uint32_array_member(struct tcb *, void *elem_buf,
844 844
 				      size_t elem_size, void *data);
845 845
 extern bool print_uint64_array_member(struct tcb *, void *elem_buf,
846 846
 				      size_t elem_size, void *data);
847
+extern bool print_xint32_array_member(struct tcb *, void *elem_buf,
848
+				      size_t elem_size, void *data);
849
+extern bool print_xint64_array_member(struct tcb *, void *elem_buf,
850
+				      size_t elem_size, void *data);
851
+
852
+static inline bool
853
+print_xlong_array_member(struct tcb *tcp, void *elem_buf, size_t elem_size,
854
+			 void *data)
855
+{
856
+	return dispatch_wordsize(print_xint64_array_member,
857
+				 print_xint32_array_member,
858
+				 tcp, elem_buf, elem_size, data);
859
+}
860
+
847 861
 
848 862
 typedef bool (*tfetch_mem_fn)(struct tcb *, kernel_ulong_t addr,
849 863
 			      unsigned int size, void *dest);

+ 32
- 15
evdev.c View File

@@ -169,27 +169,44 @@ decode_bitset(struct tcb *const tcp, const kernel_ulong_t arg,
169 169
 	if (umove_or_printaddr(tcp, arg, &decoded_arg))
170 170
 		return RVAL_IOCTL_DECODED;
171 171
 
172
-	tprints("[");
172
+	if (xlat_verbose(xlat_verbosity) != XLAT_STYLE_RAW) {
173
+		tprints("[");
173 174
 
174
-	int bit_displayed = 0;
175
-	int i = next_set_bit(decoded_arg, 0, size_bits);
176
-	if (i < 0) {
177
-		tprints(" 0 ");
178
-	} else {
179
-		printxval(decode_nr, i, dflt);
175
+		int bit_displayed = 0;
176
+		int i = next_set_bit(decoded_arg, 0, size_bits);
177
+		if (i < 0) {
178
+			tprints(" 0 ");
179
+		} else {
180
+			printxval(decode_nr, i, dflt);
180 181
 
181
-		while ((i = next_set_bit(decoded_arg, i + 1, size_bits)) > 0) {
182
-			if (abbrev(tcp) && bit_displayed >= 3) {
183
-				tprints(", ...");
184
-				break;
182
+			while ((i = next_set_bit(decoded_arg, i + 1,
183
+						 size_bits)) > 0) {
184
+				if (abbrev(tcp) && bit_displayed >= 3) {
185
+					tprints(", ...");
186
+					break;
187
+				}
188
+				tprints(", ");
189
+				printxval(decode_nr, i, dflt);
190
+				bit_displayed++;
185 191
 			}
186
-			tprints(", ");
187
-			printxval(decode_nr, i, dflt);
188
-			bit_displayed++;
189 192
 		}
193
+
194
+		tprints("]");
195
+	}
196
+
197
+	if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE)
198
+		tprints(" /* ");
199
+
200
+	if (xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV) {
201
+		uint64_t elem;
202
+
203
+		print_local_array(tcp, decoded_arg, size / current_wordsize,
204
+				  &elem, current_wordsize,
205
+				  print_xlong_array_member, NULL, 0);
190 206
 	}
191 207
 
192
-	tprints("]");
208
+	if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE)
209
+		tprints(" */");
193 210
 
194 211
 	return RVAL_IOCTL_DECODED;
195 212
 }

+ 6
- 0
tests/.gitignore View File

@@ -171,7 +171,13 @@ ioctl_dm-v
171 171
 ioctl_evdev
172 172
 ioctl_evdev-success
173 173
 ioctl_evdev-success-v
174
+ioctl_evdev-Xabbrev
175
+ioctl_evdev-Xraw
176
+ioctl_evdev-Xverbose
174 177
 ioctl_evdev-v
178
+ioctl_evdev-v-Xabbrev
179
+ioctl_evdev-v-Xraw
180
+ioctl_evdev-v-Xverbose
175 181
 ioctl_inotify
176 182
 ioctl_kvm_run
177 183
 ioctl_kvm_run-v

+ 6
- 0
tests/Makefile.am View File

@@ -106,7 +106,13 @@ check_PROGRAMS = $(PURE_EXECUTABLES) \
106 106
 	int_0x80 \
107 107
 	ioctl_dm-v \
108 108
 	ioctl_evdev-success \
109
+	ioctl_evdev-success-Xabbrev \
110
+	ioctl_evdev-success-Xraw \
111
+	ioctl_evdev-success-Xverbose \
109 112
 	ioctl_evdev-success-v \
113
+	ioctl_evdev-success-v-Xabbrev \
114
+	ioctl_evdev-success-v-Xraw \
115
+	ioctl_evdev-success-v-Xverbose \
110 116
 	ioctl_loop-nv \
111 117
 	ioctl_loop-v \
112 118
 	ioctl_nsfs \

+ 14
- 2
tests/gen_tests.in View File

@@ -139,9 +139,21 @@ io_uring_setup	-a26 -y
139 139
 ioctl_block	+ioctl.test
140 140
 ioctl_dm	+ioctl.test -s9
141 141
 ioctl_dm-v	+ioctl.test -v -s9
142
-ioctl_evdev	+ioctl.test
143
-ioctl_evdev-v	+ioctl.test -v
142
+ioctl_evdev	+ioctl.test -a26
143
+ioctl_evdev-Xabbrev	+ioctl.test -a26 -Xabbrev
144
+ioctl_evdev-Xraw	+ioctl.test -a28 -Xraw
145
+ioctl_evdev-Xverbose	+ioctl.test -a41 -Xverbose
146
+ioctl_evdev-v	+ioctl.test -a26 -v
147
+ioctl_evdev-v-Xabbrev	+ioctl.test -a26 -v -Xabbrev
148
+ioctl_evdev-v-Xraw	+ioctl.test -a28 -v -Xraw
149
+ioctl_evdev-v-Xverbose	+ioctl.test -a41 -v -Xverbose
150
+ioctl_evdev-success-Xabbrev	+ioctl_evdev-success.test -Xabbrev
151
+ioctl_evdev-success-Xraw	+ioctl_evdev-success.test -a27 -Xraw
152
+ioctl_evdev-success-Xverbose	+ioctl_evdev-success.test -a43 -Xverbose
144 153
 ioctl_evdev-success-v	+ioctl_evdev-success.test -a26 -v
154
+ioctl_evdev-success-v-Xabbrev	+ioctl_evdev-success.test -v -Xabbrev
155
+ioctl_evdev-success-v-Xraw	+ioctl_evdev-success.test -a27 -v -Xraw
156
+ioctl_evdev-success-v-Xverbose	+ioctl_evdev-success.test -a43 -v -Xverbose
145 157
 ioctl_inotify	+ioctl.test
146 158
 ioctl_kvm_run	+ioctl.test -a36 -y
147 159
 ioctl_kvm_run-v	+ioctl.test -v -a36 -y

+ 2
- 0
tests/ioctl_evdev-Xabbrev.c View File

@@ -0,0 +1,2 @@
1
+#define XLAT_ABBREV 1
2
+#include "ioctl_evdev.c"

+ 2
- 0
tests/ioctl_evdev-Xraw.c View File

@@ -0,0 +1,2 @@
1
+#define XLAT_RAW 1
2
+#include "ioctl_evdev.c"

+ 2
- 0
tests/ioctl_evdev-Xverbose.c View File

@@ -0,0 +1,2 @@
1
+#define XLAT_VERBOSE 1
2
+#include "ioctl_evdev.c"

+ 2
- 0
tests/ioctl_evdev-success-Xabbrev.c View File

@@ -0,0 +1,2 @@
1
+#define XLAT_ABBREV 1
2
+#include "ioctl_evdev-success.c"

+ 2
- 0
tests/ioctl_evdev-success-Xraw.c View File

@@ -0,0 +1,2 @@
1
+#define XLAT_RAW 1
2
+#include "ioctl_evdev-success.c"

+ 2
- 0
tests/ioctl_evdev-success-Xverbose.c View File

@@ -0,0 +1,2 @@
1
+#define XLAT_VERBOSE 1
2
+#include "ioctl_evdev-success.c"

+ 2
- 0
tests/ioctl_evdev-success-v-Xabbrev.c View File

@@ -0,0 +1,2 @@
1
+#define XLAT_ABBREV 1
2
+#include "ioctl_evdev-success-v.c"

+ 2
- 0
tests/ioctl_evdev-success-v-Xraw.c View File

@@ -0,0 +1,2 @@
1
+#define XLAT_RAW 1
2
+#include "ioctl_evdev-success-v.c"

+ 2
- 0
tests/ioctl_evdev-success-v-Xverbose.c View File

@@ -0,0 +1,2 @@
1
+#define XLAT_VERBOSE 1
2
+#include "ioctl_evdev-success-v.c"

+ 63
- 14
tests/ioctl_evdev-success.c View File

@@ -44,7 +44,7 @@ static void
44 44
 test_evdev(struct evdev_check *check, const void *arg)
45 45
 {
46 46
 	long rc = invoke_test_syscall(check->cmd, check->arg_ptr);
47
-	printf("ioctl(-1, %s, ", check->cmd_str);
47
+	printf("ioctl(-1, %s, ", sprintxlat(check->cmd_str, check->cmd, NULL));
48 48
 	if (check->print_arg)
49 49
 		check->print_arg(rc, check->arg_ptr, arg);
50 50
 	else
@@ -115,26 +115,52 @@ print_mtslots(long rc, const void *ptr, const void *arg)
115 115
 static void
116 116
 print_getbit(long rc, const void *ptr, const void *arg)
117 117
 {
118
-	const char * const *str = arg;
118
+	const char * const *str = arg + sizeof(char *);
119
+# if XLAT_RAW || XLAT_VERBOSE
120
+	const unsigned long *buf = ptr;
121
+	const unsigned long buf_size = (uintptr_t) (str[-1]);
122
+# endif
123
+
124
+
119 125
 
120 126
 	if (rc <= 0) {
121 127
 		printf("%p", ptr);
122 128
 		return;
123 129
 	}
124 130
 
131
+# if !XLAT_RAW
125 132
 	printf("[");
126 133
 	for (unsigned long i = 0; str[i]; i++) {
127
-# if ! VERBOSE
134
+#  if ! VERBOSE
128 135
 		if (i >= 4) {
129 136
 			printf(", ...");
130 137
 			break;
131 138
 		}
132
-# endif
139
+#  endif
133 140
 		if (i)
134 141
 			printf(", ");
135 142
 		printf("%s", str[i]);
136 143
 	}
137 144
 	printf("]");
145
+# endif /* !XLAT_RAW */
146
+
147
+# if XLAT_VERBOSE
148
+	printf(" /* ");
149
+# endif
150
+
151
+# if XLAT_RAW || XLAT_VERBOSE
152
+	printf("[");
153
+	const unsigned long cnt =
154
+		(MIN((unsigned long) rc, buf_size) + sizeof(long) - 1)
155
+		/ sizeof(long);
156
+	for (unsigned long i = 0; i < cnt; i++)
157
+		printf("%s%#lx", i ? ", " : "", buf[i]);
158
+	printf("]");
159
+# endif
160
+
161
+# if XLAT_VERBOSE
162
+	printf(" */");
163
+# endif
138 164
 }
139 165
 
140 166
 int
@@ -159,8 +185,8 @@ main(int argc, char **argv)
159 185
 
160 186
 	for (unsigned int i = 0; i < num_skip; i++) {
161 187
 		long rc = ioctl(-1, EVIOCGID, NULL);
162
-		printf("ioctl(-1, EVIOCGID, NULL) = %s%s\n",
163
-		       sprintrc(rc),
188
+		printf("ioctl(-1, %s, NULL) = %s%s\n",
189
+		       XLAT_STR(EVIOCGID), sprintrc(rc),
164 190
 		       rc == inject_retval ? " (INJECTED)" : "");
165 191
 
166 192
 		if (rc != inject_retval)
@@ -187,7 +213,18 @@ main(int argc, char **argv)
187 213
 	/* invalid flag */
188 214
 	static const unsigned int invalid_mtslot[] = { -1, 1 };
189 215
 	static const char * const invalid_mtslot_str[] = {
190
-		"0xffffffff /* ABS_MT_??? */", "1", NULL };
216
+		""
217
+#  if !XLAT_RAW && !XLAT_VERBOSE
218
+		"0xffffffff"
219
+#  endif
220
+#  if !XLAT_VERBOSE
221
+		" /* "
222
+#  endif
223
+		"ABS_MT_???"
224
+#  if !XLAT_VERBOSE
225
+		" */"
226
+#  endif
227
+		, "1", NULL };
191 228
 # endif
192 229
 
193 230
 	enum { ULONG_BIT = sizeof(unsigned long) * 8 };
@@ -197,21 +234,30 @@ main(int argc, char **argv)
197 234
 		1 << EV_ABS | 1 << EV_MSC | 1 << EV_LED | 1 << EV_SND
198 235
 		| 1 << EV_PWR };
199 236
 	static const char * const ev_more_str_2[] = {
200
-		"EV_ABS", "EV_MSC", NULL };
237
+		(char *) (uintptr_t) 4,
238
+		XLAT_KNOWN(0x3, "EV_ABS"), XLAT_KNOWN(0x4, "EV_MSC"), NULL };
201 239
 	static const char * const ev_more_str_3[] = {
202
-		"EV_ABS", "EV_MSC", "EV_LED", "EV_SND", "EV_PWR", NULL };
240
+		(char *) (uintptr_t) 4,
241
+		XLAT_KNOWN(0x3, "EV_ABS"), XLAT_KNOWN(0x4, "EV_MSC"),
242
+		XLAT_KNOWN(0x11, "EV_LED"), XLAT_KNOWN(0x12, "EV_SND"),
243
+		XLAT_KNOWN(0x16, "EV_PWR"), NULL };
203 244
 
204 245
 	/* set less than 4 bits */
205 246
 	static const unsigned long ev_less[NUM_WORDS] = {
206 247
 		1 << EV_ABS | 1 << EV_MSC | 1 << EV_LED };
207 248
 	static const char * const ev_less_str_2[] = {
208
-		"EV_ABS", "EV_MSC", NULL };
249
+		(char *) (uintptr_t) 4,
250
+		XLAT_KNOWN(0x3, "EV_ABS"), XLAT_KNOWN(0x4, "EV_MSC"), NULL };
209 251
 	static const char * const ev_less_str_3[] = {
210
-		"EV_ABS", "EV_MSC", "EV_LED", NULL };
252
+		(char *) (uintptr_t) 4,
253
+		XLAT_KNOWN(0x3, "EV_ABS"), XLAT_KNOWN(0x4, "EV_MSC"),
254
+		XLAT_KNOWN(0x11, "EV_LED"), NULL };
211 255
 
212 256
 	/* set zero bit */
213 257
 	static const unsigned long ev_zero[NUM_WORDS] = { 0x0 };
214
-	static const char * const ev_zero_str[] = { " 0 ", NULL };
258
+	static const char * const ev_zero_str[] = {
259
+		(char *) (uintptr_t) 1,
260
+		" 0 ", NULL };
215 261
 
216 262
 	/* KEY_MAX is 0x2ff which is greater than retval * 8 */
217 263
 	static const unsigned long key[NUM_WORDS] = {
@@ -219,9 +265,12 @@ main(int argc, char **argv)
219 265
 		[ KEY_F12 / ULONG_BIT ] = 1 << (KEY_F12 % ULONG_BIT) };
220 266
 
221 267
 	static const char * const key_str_8[] = {
222
-		"KEY_1", "KEY_2", NULL };
268
+		(char *) (uintptr_t) (NUM_WORDS * sizeof(long)),
269
+		XLAT_KNOWN(0x2, "KEY_1"), XLAT_KNOWN(0x3, "KEY_2"), NULL };
223 270
 	static const char * const key_str_16[] = {
224
-		"KEY_1", "KEY_2", "KEY_F12", NULL };
271
+		(char *) (uintptr_t) (NUM_WORDS * sizeof(long)),
272
+		XLAT_KNOWN(0x2, "KEY_1"), XLAT_KNOWN(0x3, "KEY_2"),
273
+		XLAT_KNOWN(0x58, "KEY_F12"), NULL };
225 274
 
226 275
 	assert(sizeof(ev_more) >= (unsigned long) inject_retval);
227 276
 	assert(sizeof(ev_less) >= (unsigned long) inject_retval);

+ 2
- 0
tests/ioctl_evdev-v-Xabbrev.c View File

@@ -0,0 +1,2 @@
1
+#define XLAT_ABBREV 1
2
+#include "ioctl_evdev-v.c"

+ 2
- 0
tests/ioctl_evdev-v-Xraw.c View File

@@ -0,0 +1,2 @@
1
+#define XLAT_RAW 1
2
+#include "ioctl_evdev-v.c"

+ 2
- 0
tests/ioctl_evdev-v-Xverbose.c View File

@@ -0,0 +1,2 @@
1
+#define XLAT_VERBOSE 1
2
+#include "ioctl_evdev-v.c"

+ 70
- 31
tests/ioctl_evdev.c View File

@@ -26,6 +26,12 @@
26 26
 #  define ABS_MT_TOOL_Y 0x3d
27 27
 # endif
28 28
 
29
+# if XLAT_VERBOSE
30
+#  define UNK_CMD(val_, str_) val_
31
+# else
32
+#  define UNK_CMD(val_, str_) val_ " /* " str_ " */"
33
+# endif
34
+
29 35
 static const unsigned int magic = 0xdeadbeef;
30 36
 static const unsigned long lmagic = (unsigned long) 0xdeadbeefbadc0dedULL;
31 37
 
@@ -43,9 +49,11 @@ print_envelope(const struct ff_envelope *const e)
43 49
 static void
44 50
 print_ffe_common(const struct ff_effect *const ffe, const char *const type_str)
45 51
 {
46
-	printf("ioctl(-1, EVIOCSFF, {type=%s, id=%" PRIu16
52
+	printf("ioctl(-1, %s", XLAT_STR(EVIOCSFF));
53
+	printf(", {type=%s, id=%" PRIu16
47 54
 	       ", direction=%" PRIu16 ", ",
48
-	       type_str, ffe->id, ffe->direction);
55
+	       sprintxlat(type_str, ffe->type, NULL),
56
+	       ffe->id, ffe->direction);
49 57
 # if VERBOSE
50 58
 	printf("trigger={button=%hu, interval=%hu}"
51 59
 	       ", replay={length=%hu, delay=%hu}",
@@ -54,10 +62,11 @@ print_ffe_common(const struct ff_effect *const ffe, const char *const type_str)
54 62
 # endif /* VERBOSE */
55 63
 }
56 64
 
57
-# define TEST_NULL_ARG_EX(cmd, str)						\
65
+# define TEST_NULL_ARG_EX(cmd, str)					\
58 66
 	do {								\
59 67
 		ioctl(-1, cmd, 0);					\
60
-		printf("ioctl(-1, %s, NULL) = -1 EBADF (%m)\n", str);	\
68
+		printf("ioctl(-1, %s, NULL) = -1 EBADF (%m)\n",		\
69
+		       sprintxlat(str, cmd, NULL));			\
61 70
 	} while (0)
62 71
 
63 72
 # define TEST_NULL_ARG(cmd) TEST_NULL_ARG_EX(cmd, #cmd)
@@ -107,17 +116,23 @@ main(void)
107 116
 	TEST_NULL_ARG(EVIOCGABS(ABS_X));
108 117
 	TEST_NULL_ARG(EVIOCSABS(ABS_X));
109 118
 
110
-	TEST_NULL_ARG_EX(EVIOCGABS(0xe), "EVIOCGABS(0xe /* ABS_??? */)");
111
-	TEST_NULL_ARG_EX(EVIOCSABS(0xe), "EVIOCSABS(0xe /* ABS_??? */)");
119
+	TEST_NULL_ARG_EX(EVIOCGABS(0xe),
120
+			 "EVIOCGABS(" UNK_CMD("0xe", "ABS_???") ")");
121
+	TEST_NULL_ARG_EX(EVIOCSABS(0xe),
122
+			 "EVIOCSABS(" UNK_CMD("0xe", "ABS_???") ")");
112 123
 
113 124
 	TEST_NULL_ARG(EVIOCGABS(ABS_MT_TOOL_Y));
114 125
 	TEST_NULL_ARG(EVIOCSABS(ABS_MT_TOOL_Y));
115 126
 
116
-	TEST_NULL_ARG_EX(EVIOCGABS(0x3e), "EVIOCGABS(0x3e /* ABS_??? */)");
117
-	TEST_NULL_ARG_EX(EVIOCSABS(0x3e), "EVIOCSABS(0x3e /* ABS_??? */)");
127
+	TEST_NULL_ARG_EX(EVIOCGABS(0x3e),
128
+			 "EVIOCGABS(" UNK_CMD("0x3e", "ABS_???") ")");
129
+	TEST_NULL_ARG_EX(EVIOCSABS(0x3e),
130
+			 "EVIOCSABS(" UNK_CMD("0x3e", "ABS_???") ")");
118 131
 
119
-	TEST_NULL_ARG_EX(EVIOCGABS(0x3f), "EVIOCGABS(0x3f /* ABS_??? */)");
120
-	TEST_NULL_ARG_EX(EVIOCSABS(0x3f), "EVIOCSABS(0x3f /* ABS_??? */)");
132
+	TEST_NULL_ARG_EX(EVIOCGABS(0x3f),
133
+			 "EVIOCGABS(" UNK_CMD("0x3f", "ABS_???") ")");
134
+	TEST_NULL_ARG_EX(EVIOCSABS(0x3f),
135
+			 "EVIOCSABS(" UNK_CMD("0x3f", "ABS_???") ")");
121 136
 
122 137
 	TEST_NULL_ARG(EVIOCGBIT(0, 0));
123 138
 	TEST_NULL_ARG(EVIOCGBIT(EV_KEY, 1));
@@ -132,25 +147,36 @@ main(void)
132 147
 	TEST_NULL_ARG(EVIOCGBIT(EV_PWR, 10));
133 148
 	TEST_NULL_ARG(EVIOCGBIT(EV_FF_STATUS, 11));
134 149
 
135
-	TEST_NULL_ARG_EX(EVIOCGBIT(0x6, 12), "EVIOCGBIT(0x6 /* EV_??? */, 12)");
150
+	TEST_NULL_ARG_EX(EVIOCGBIT(0x6, 12),
151
+			 "EVIOCGBIT(" UNK_CMD("0x6", "EV_???") ", 12)");
136 152
 	TEST_NULL_ARG_EX(EVIOCGBIT(0x18, 13),
137
-			 "EVIOCGBIT(0x18 /* EV_??? */, 13)");
153
+			 "EVIOCGBIT(" UNK_CMD("0x18", "EV_???") ", 13)");
138 154
 	TEST_NULL_ARG_EX(EVIOCGBIT(0x1f, 14),
139
-			 "EVIOCGBIT(0x1f /* EV_??? */, 14)");
155
+			 "EVIOCGBIT(" UNK_CMD("0x1f", "EV_???") ", 14)");
140 156
 
141 157
 	ioctl(-1, EVIOCGBIT(EV_MAX, 42), 0);
142
-	printf("ioctl(-1, EVIOCGBIT(%#x /* EV_??? */, 42), NULL)"
143
-	       " = -1 EBADF (%m)\n", EV_MAX);
158
+	printf("ioctl(-1, ");
159
+# if XLAT_RAW
160
+	printf("%#x", EVIOCGBIT(EV_MAX, 42));
161
+# elif XLAT_VERBOSE
162
+	printf("%#x /* EVIOCGBIT(%#x, 42) */", EVIOCGBIT(EV_MAX, 42), EV_MAX);
163
+# else
164
+	printf("EVIOCGBIT(%#x /* EV_??? */, 42)", EV_MAX);
165
+# endif
166
+	printf(", NULL) = -1 EBADF (%m)\n");
144 167
 
145 168
 	ioctl(-1, EVIOCRMFF, lmagic);
146
-	printf("ioctl(-1, EVIOCRMFF, %d) = -1 EBADF (%m)\n", (int) lmagic);
169
+	printf("ioctl(-1, %s, %d) = -1 EBADF (%m)\n",
170
+	       XLAT_STR(EVIOCRMFF), (int) lmagic);
147 171
 
148 172
 	ioctl(-1, EVIOCGRAB, lmagic);
149
-	printf("ioctl(-1, EVIOCGRAB, %lu) = -1 EBADF (%m)\n", lmagic);
173
+	printf("ioctl(-1, %s, %lu) = -1 EBADF (%m)\n",
174
+	       XLAT_STR(EVIOCGRAB), lmagic);
150 175
 
151 176
 # ifdef EVIOCREVOKE
152 177
 	ioctl(-1, EVIOCREVOKE, lmagic);
153
-	printf("ioctl(-1, EVIOCREVOKE, %lu) = -1 EBADF (%m)\n", lmagic);
178
+	printf("ioctl(-1, %s, %lu) = -1 EBADF (%m)\n",
179
+	       XLAT_STR(EVIOCREVOKE), lmagic);
154 180
 # endif
155 181
 
156 182
 	const unsigned int size = get_page_size();
@@ -162,7 +188,8 @@ main(void)
162 188
 
163 189
 # ifdef EVIOCSCLOCKID
164 190
 	ioctl(-1, EVIOCSCLOCKID, val_int);
165
-	printf("ioctl(-1, EVIOCSCLOCKID, [%u]) = -1 EBADF (%m)\n", *val_int);
191
+	printf("ioctl(-1, %s, [%u]) = -1 EBADF (%m)\n",
192
+	       XLAT_STR(EVIOCSCLOCKID), *val_int);
166 193
 # endif
167 194
 
168 195
 	int *pair_int = tail_alloc(sizeof(*pair_int) * 2);
@@ -171,14 +198,15 @@ main(void)
171 198
 
172 199
 # ifdef EVIOSGREP
173 200
 	ioctl(-1, EVIOCSREP, pair_int);
174
-	printf("ioctl(-1, EVIOCSREP, [%u, %u]) = -1 EBADF (%m)\n",
175
-	       pair_int[0], pair_int[1]);
201
+	printf("ioctl(-1, %s, [%u, %u]) = -1 EBADF (%m)\n",
202
+	       XLAT_STR(EVIOCSREP), pair_int[0], pair_int[1]);
176 203
 # endif
177 204
 
178 205
 	pair_int[1] = 1;
179 206
 	ioctl(-1, EVIOCSKEYCODE, pair_int);
180
-	printf("ioctl(-1, EVIOCSKEYCODE, [%u, %s]) = -1 EBADF (%m)\n",
181
-	       pair_int[0], "KEY_ESC");
207
+	printf("ioctl(-1, %s, [%u, %s]) = -1 EBADF (%m)\n",
208
+	       XLAT_STR(EVIOCSKEYCODE), pair_int[0],
209
+	       XLAT_KNOWN(0x1, "KEY_ESC"));
182 210
 
183 211
 # ifdef EVIOCSKEYCODE_V2
184 212
 	TAIL_ALLOC_OBJECT_CONST_PTR(struct input_keymap_entry, ike);
@@ -186,11 +214,11 @@ main(void)
186 214
 	ike->keycode = 2;
187 215
 
188 216
 	ioctl(-1, EVIOCSKEYCODE_V2, ike);
189
-	printf("ioctl(-1, EVIOCSKEYCODE_V2, {flags=%" PRIu8
190
-	       ", len=%" PRIu8 ", ", ike->flags, ike->len);
217
+	printf("ioctl(-1, %s, {flags=%" PRIu8 ", len=%" PRIu8 ", ",
218
+	       XLAT_STR(EVIOCSKEYCODE_V2), ike->flags, ike->len);
191 219
 #  if VERBOSE
192 220
 	printf("index=%" PRIu16 ", keycode=%s, scancode=[",
193
-	       ike->index, "KEY_1");
221
+	       ike->index, XLAT_STR(KEY_1));
194 222
 	unsigned int i;
195 223
 	for (i = 0; i < ARRAY_SIZE(ike->scancode); ++i) {
196 224
 		if (i > 0)
@@ -256,26 +284,37 @@ main(void)
256 284
 
257 285
 	ffe->type = 0xff;
258 286
 	ioctl(-1, EVIOCSFF, ffe);
259
-	print_ffe_common(ffe, "0xff /* FF_??? */");
287
+	print_ffe_common(ffe,
288
+#  if !XLAT_RAW && !XLAT_VERBOSE
289
+		"0xff"
290
+#  endif
291
+#  if !XLAT_VERBOSE
292
+		" /* "
293
+#  endif
294
+		"FF_???"
295
+#  if !XLAT_VERBOSE
296
+		" */"
297
+#  endif
298
+		);
260 299
 	errno = EBADF;
261 300
 	printf("}) = -1 EBADF (%m)\n");
262 301
 # endif
263 302
 
264 303
 	ioctl(-1, _IOC(_IOC_READ, 0x45, 0x1, 0xff), lmagic);
265 304
 	printf("ioctl(-1, %s, %#lx) = -1 EBADF (%m)\n",
266
-	       "_IOC(_IOC_READ, 0x45, 0x1, 0xff)", lmagic);
305
+	       XLAT_STR(_IOC(_IOC_READ, 0x45, 0x1, 0xff)), lmagic);
267 306
 
268 307
 	ioctl(-1, _IOC(_IOC_WRITE, 0x45, 0x1, 0xff), lmagic);
269 308
 	printf("ioctl(-1, %s, %#lx) = -1 EBADF (%m)\n",
270
-	       "_IOC(_IOC_WRITE, 0x45, 0x1, 0xff)", lmagic);
309
+	       XLAT_STR(_IOC(_IOC_WRITE, 0x45, 0x1, 0xff)), lmagic);
271 310
 
272 311
 	ioctl(-1, _IOC(_IOC_READ|_IOC_WRITE, 0x45, 0xfe, 0xff), lmagic);
273 312
 	printf("ioctl(-1, %s, %#lx) = -1 EBADF (%m)\n",
274
-	       "_IOC(_IOC_READ|_IOC_WRITE, 0x45, 0xfe, 0xff)", lmagic);
313
+	       XLAT_STR(_IOC(_IOC_READ|_IOC_WRITE, 0x45, 0xfe, 0xff)), lmagic);
275 314
 
276 315
 	ioctl(-1, _IOC(_IOC_READ|_IOC_WRITE, 0x45, 0, 0), lmagic);
277 316
 	printf("ioctl(-1, %s, %#lx) = -1 EBADF (%m)\n",
278
-	       "_IOC(_IOC_READ|_IOC_WRITE, 0x45, 0, 0)", lmagic);
317
+	       XLAT_STR(_IOC(_IOC_READ|_IOC_WRITE, 0x45, 0, 0)), lmagic);
279 318
 
280 319
 	puts("+++ exited with 0 +++");
281 320
 	return 0;

+ 6
- 0
tests/pure_executables.list View File

@@ -141,7 +141,13 @@ ioctl
141 141
 ioctl_block
142 142
 ioctl_dm
143 143
 ioctl_evdev
144
+ioctl_evdev-Xabbrev
145
+ioctl_evdev-Xraw
146
+ioctl_evdev-Xverbose
144 147
 ioctl_evdev-v
148
+ioctl_evdev-v-Xabbrev
149
+ioctl_evdev-v-Xraw
150
+ioctl_evdev-v-Xverbose
145 151
 ioctl_inotify
146 152
 ioctl_kvm_run
147 153
 ioctl_kvm_run-v

+ 18
- 0
util.c View File

@@ -1240,6 +1240,24 @@ print_uint64_array_member(struct tcb *tcp, void *elem_buf, size_t elem_size,
1240 1240
 	return true;
1241 1241
 }
1242 1242
 
1243
+bool
1244
+print_xint32_array_member(struct tcb *tcp, void *elem_buf, size_t elem_size,
1245
+			  void *data)
1246
+{
1247
+	tprintf("%#" PRIx32, *(uint32_t *) elem_buf);
1248
+
1249
+	return true;
1250
+}
1251
+
1252
+bool
1253
+print_xint64_array_member(struct tcb *tcp, void *elem_buf, size_t elem_size,
1254
+			  void *data)
1255
+{
1256
+	tprintf("%#" PRIx64, *(uint64_t *) elem_buf);
1257
+
1258
+	return true;
1259
+}
1260
+
1243 1261
 /*
1244 1262
  * Iteratively fetch and print up to nmemb elements of elem_size size
1245 1263
  * from the array that starts at tracee's address start_addr.

Loading…
Cancel
Save