diff options
| author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-04-26 10:03:03 -0400 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-04-26 12:14:59 -0400 |
| commit | 62de344e4fed23a42048c02dfa841f7d7ce9e88e (patch) | |
| tree | 40e8574862c7227a68ac01a7434289c16878c04a /tools/perf/trace | |
| parent | 2a12ec13cc4ca8690ad2690c09bf8bff17c228d9 (diff) | |
perf trace: Move perf_flags beautifier to tools/perf/trace/beauty/
To reduce the size of builtin-trace.c.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-8r3gmymyn3r0ynt4yuzspp9g@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/trace')
| -rw-r--r-- | tools/perf/trace/beauty/perf_event_open.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tools/perf/trace/beauty/perf_event_open.c b/tools/perf/trace/beauty/perf_event_open.c new file mode 100644 index 000000000000..311f09dd718d --- /dev/null +++ b/tools/perf/trace/beauty/perf_event_open.c | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | #ifndef PERF_FLAG_FD_NO_GROUP | ||
| 2 | # define PERF_FLAG_FD_NO_GROUP (1UL << 0) | ||
| 3 | #endif | ||
| 4 | |||
| 5 | #ifndef PERF_FLAG_FD_OUTPUT | ||
| 6 | # define PERF_FLAG_FD_OUTPUT (1UL << 1) | ||
| 7 | #endif | ||
| 8 | |||
| 9 | #ifndef PERF_FLAG_PID_CGROUP | ||
| 10 | # define PERF_FLAG_PID_CGROUP (1UL << 2) /* pid=cgroup id, per-cpu mode only */ | ||
| 11 | #endif | ||
| 12 | |||
| 13 | #ifndef PERF_FLAG_FD_CLOEXEC | ||
| 14 | # define PERF_FLAG_FD_CLOEXEC (1UL << 3) /* O_CLOEXEC */ | ||
| 15 | #endif | ||
| 16 | |||
| 17 | static size_t syscall_arg__scnprintf_perf_flags(char *bf, size_t size, | ||
| 18 | struct syscall_arg *arg) | ||
| 19 | { | ||
| 20 | int printed = 0, flags = arg->val; | ||
| 21 | |||
| 22 | if (flags == 0) | ||
| 23 | return 0; | ||
| 24 | |||
| 25 | #define P_FLAG(n) \ | ||
| 26 | if (flags & PERF_FLAG_##n) { \ | ||
| 27 | printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ | ||
| 28 | flags &= ~PERF_FLAG_##n; \ | ||
| 29 | } | ||
| 30 | |||
| 31 | P_FLAG(FD_NO_GROUP); | ||
| 32 | P_FLAG(FD_OUTPUT); | ||
| 33 | P_FLAG(PID_CGROUP); | ||
| 34 | P_FLAG(FD_CLOEXEC); | ||
| 35 | #undef P_FLAG | ||
| 36 | |||
| 37 | if (flags) | ||
| 38 | printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); | ||
| 39 | |||
| 40 | return printed; | ||
| 41 | } | ||
| 42 | |||
| 43 | #define SCA_PERF_FLAGS syscall_arg__scnprintf_perf_flags | ||
