Skip to content

Commit 3258abe

Browse files
committed
perf trace beauty futex: Beautify FUTEX_BITSET_MATCH_ANY
E.g.: # strace -e futex -p 14437 strace: Process 14437 attached futex(0x7f46f4808d70, FUTEX_WAKE_PRIVATE, 1) = 0 futex(0x7f46f24e68b0, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, {tv_sec=1516636744, tv_nsec=221969000}, 0xffffffff) = -1 ETIMEDOUT (Connection timed out) <detached ...> # Should pretty print that 0xffffffff value, like: # trace -e futex --tid 14437 0.028 ( 0.005 ms): futex(uaddr: 0x7f46f4808d70, op: WAKE|PRIV, val: 1 ) = 0 0.037 (1000.092 ms): futex(uaddr: 0x7f46f24e68b0, op: WAIT_BITSET|PRIV|CLKRT, utime: 0x7f46f23fedf0, val3: MATCH_ANY) = -1 ETIMEDOUT Connection timed out ^C# Cc: Adrian Hunter <[email protected]> Cc: David Ahern <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Wang Nan <[email protected]> Link: https://lkml.kernel.org/n/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 522283f commit 3258abe

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

tools/perf/builtin-trace.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ static size_t syscall_arg__scnprintf_getrandom_flags(char *bf, size_t size,
549549
#include "trace/beauty/eventfd.c"
550550
#include "trace/beauty/flock.c"
551551
#include "trace/beauty/futex_op.c"
552+
#include "trace/beauty/futex_val3.c"
552553
#include "trace/beauty/mmap.c"
553554
#include "trace/beauty/mode_t.c"
554555
#include "trace/beauty/msg_flags.c"
@@ -611,7 +612,8 @@ static struct syscall_fmt {
611612
{ .name = "fstat", .alias = "newfstat", },
612613
{ .name = "fstatat", .alias = "newfstatat", },
613614
{ .name = "futex",
614-
.arg = { [1] = { .scnprintf = SCA_FUTEX_OP, /* op */ }, }, },
615+
.arg = { [1] = { .scnprintf = SCA_FUTEX_OP, /* op */ },
616+
[5] = { .scnprintf = SCA_FUTEX_VAL3, /* val3 */ }, }, },
615617
{ .name = "futimesat",
616618
.arg = { [0] = { .scnprintf = SCA_FDAT, /* fd */ }, }, },
617619
{ .name = "getitimer",

tools/perf/trace/beauty/futex_val3.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
#include <linux/futex.h>
3+
4+
#ifndef FUTEX_BITSET_MATCH_ANY
5+
#define FUTEX_BITSET_MATCH_ANY 0xffffffff
6+
#endif
7+
8+
static size_t syscall_arg__scnprintf_futex_val3(char *bf, size_t size, struct syscall_arg *arg)
9+
{
10+
unsigned int bitset = arg->val;
11+
12+
if (bitset == FUTEX_BITSET_MATCH_ANY)
13+
return scnprintf(bf, size, "MATCH_ANY");
14+
15+
return scnprintf(bf, size, "%#xd", bitset);
16+
}
17+
18+
#define SCA_FUTEX_VAL3 syscall_arg__scnprintf_futex_val3

0 commit comments

Comments
 (0)