aboutsummaryrefslogtreecommitdiff
path: root/linux-user
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2022-08-28 19:10:04 -0700
committerLaurent Vivier <laurent@vivier.eu>2022-09-27 13:19:05 +0200
commit53b578f31fda28b2cf83ca28d0c7a5159416d32b (patch)
tree5a88ca7433c0f812fd146c15c1db11fb16f6916f /linux-user
parentc72a90df47b990572ac4fdb7e918005466446db9 (diff)
linux-user: Update print_futex_op
Use a table for the names; print unknown values in hex, since the value contains flags. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220829021006.67305-7-richard.henderson@linaro.org> [lv: update print_futex() according to "linux-user: Show timespec on strace for futex()"] Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Diffstat (limited to 'linux-user')
-rw-r--r--linux-user/strace.c70
1 files changed, 33 insertions, 37 deletions
diff --git a/linux-user/strace.c b/linux-user/strace.c
index 2deb84a2c1..faa7331256 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -3710,44 +3710,37 @@ print_munmap(CPUArchState *cpu_env, const struct syscallname *name,
#endif
#ifdef TARGET_NR_futex
-static void print_futex_op(abi_long tflag, int last)
-{
-#define print_op(val) \
-if( cmd == val ) { \
- qemu_log(#val); \
- return; \
-}
-
- int cmd = (int)tflag;
-#ifdef FUTEX_PRIVATE_FLAG
- if (cmd & FUTEX_PRIVATE_FLAG) {
- qemu_log("FUTEX_PRIVATE_FLAG|");
- cmd &= ~FUTEX_PRIVATE_FLAG;
- }
-#endif
-#ifdef FUTEX_CLOCK_REALTIME
- if (cmd & FUTEX_CLOCK_REALTIME) {
- qemu_log("FUTEX_CLOCK_REALTIME|");
- cmd &= ~FUTEX_CLOCK_REALTIME;
+static void print_futex_op(int cmd, int last)
+{
+ static const char * const futex_names[] = {
+#define NAME(X) [X] = #X
+ NAME(FUTEX_WAIT),
+ NAME(FUTEX_WAKE),
+ NAME(FUTEX_FD),
+ NAME(FUTEX_REQUEUE),
+ NAME(FUTEX_CMP_REQUEUE),
+ NAME(FUTEX_WAKE_OP),
+ NAME(FUTEX_LOCK_PI),
+ NAME(FUTEX_UNLOCK_PI),
+ NAME(FUTEX_TRYLOCK_PI),
+ NAME(FUTEX_WAIT_BITSET),
+ NAME(FUTEX_WAKE_BITSET),
+ NAME(FUTEX_WAIT_REQUEUE_PI),
+ NAME(FUTEX_CMP_REQUEUE_PI),
+ NAME(FUTEX_LOCK_PI2),
+#undef NAME
+ };
+
+ unsigned base_cmd = cmd & FUTEX_CMD_MASK;
+
+ if (base_cmd < ARRAY_SIZE(futex_names)) {
+ qemu_log("%s%s%s",
+ (cmd & FUTEX_PRIVATE_FLAG ? "FUTEX_PRIVATE_FLAG|" : ""),
+ (cmd & FUTEX_CLOCK_REALTIME ? "FUTEX_CLOCK_REALTIME|" : ""),
+ futex_names[base_cmd]);
+ } else {
+ qemu_log("0x%x", cmd);
}
-#endif
- print_op(FUTEX_WAIT)
- print_op(FUTEX_WAKE)
- print_op(FUTEX_FD)
- print_op(FUTEX_REQUEUE)
- print_op(FUTEX_CMP_REQUEUE)
- print_op(FUTEX_WAKE_OP)
- print_op(FUTEX_LOCK_PI)
- print_op(FUTEX_UNLOCK_PI)
- print_op(FUTEX_TRYLOCK_PI)
-#ifdef FUTEX_WAIT_BITSET
- print_op(FUTEX_WAIT_BITSET)
-#endif
-#ifdef FUTEX_WAKE_BITSET
- print_op(FUTEX_WAKE_BITSET)
-#endif
- /* unknown values */
- qemu_log("%d", cmd);
}
static void
@@ -3763,6 +3756,9 @@ print_futex(CPUArchState *cpu_env, const struct syscallname *name,
switch (op) {
case FUTEX_WAIT:
case FUTEX_WAIT_BITSET:
+ case FUTEX_LOCK_PI:
+ case FUTEX_LOCK_PI2:
+ case FUTEX_WAIT_REQUEUE_PI:
print_timespec(arg3, 0);
break;
default: