diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-04-27 18:01:52 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-04-28 08:58:59 -0400 |
commit | a30e6259b5e31e8d2b40f3b0099d98a6ebe0e360 (patch) | |
tree | dab2e65adae03544633c2ca71928200d74713369 | |
parent | be7b0c9e376e93a00b6c8631e2721e9dc7c6a1fa (diff) |
perf trace: Move msg_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-11zxg3qitk6bw2x30135k9z4@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/builtin-trace.c | 62 | ||||
-rw-r--r-- | tools/perf/trace/beauty/msg_flags.c | 62 |
2 files changed, 63 insertions, 61 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index f4f3389c92c7..9e38fe973f0c 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -52,10 +52,6 @@ | |||
52 | # define O_CLOEXEC 02000000 | 52 | # define O_CLOEXEC 02000000 |
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | #ifndef MSG_CMSG_CLOEXEC | ||
56 | # define MSG_CMSG_CLOEXEC 0x40000000 | ||
57 | #endif | ||
58 | |||
59 | struct trace { | 55 | struct trace { |
60 | struct perf_tool tool; | 56 | struct perf_tool tool; |
61 | struct syscalltbl *sctbl; | 57 | struct syscalltbl *sctbl; |
@@ -513,63 +509,6 @@ static const char *socket_families[] = { | |||
513 | }; | 509 | }; |
514 | static DEFINE_STRARRAY(socket_families); | 510 | static DEFINE_STRARRAY(socket_families); |
515 | 511 | ||
516 | #ifndef MSG_PROBE | ||
517 | #define MSG_PROBE 0x10 | ||
518 | #endif | ||
519 | #ifndef MSG_WAITFORONE | ||
520 | #define MSG_WAITFORONE 0x10000 | ||
521 | #endif | ||
522 | #ifndef MSG_SENDPAGE_NOTLAST | ||
523 | #define MSG_SENDPAGE_NOTLAST 0x20000 | ||
524 | #endif | ||
525 | #ifndef MSG_FASTOPEN | ||
526 | #define MSG_FASTOPEN 0x20000000 | ||
527 | #endif | ||
528 | |||
529 | static size_t syscall_arg__scnprintf_msg_flags(char *bf, size_t size, | ||
530 | struct syscall_arg *arg) | ||
531 | { | ||
532 | int printed = 0, flags = arg->val; | ||
533 | |||
534 | if (flags == 0) | ||
535 | return scnprintf(bf, size, "NONE"); | ||
536 | #define P_MSG_FLAG(n) \ | ||
537 | if (flags & MSG_##n) { \ | ||
538 | printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ | ||
539 | flags &= ~MSG_##n; \ | ||
540 | } | ||
541 | |||
542 | P_MSG_FLAG(OOB); | ||
543 | P_MSG_FLAG(PEEK); | ||
544 | P_MSG_FLAG(DONTROUTE); | ||
545 | P_MSG_FLAG(TRYHARD); | ||
546 | P_MSG_FLAG(CTRUNC); | ||
547 | P_MSG_FLAG(PROBE); | ||
548 | P_MSG_FLAG(TRUNC); | ||
549 | P_MSG_FLAG(DONTWAIT); | ||
550 | P_MSG_FLAG(EOR); | ||
551 | P_MSG_FLAG(WAITALL); | ||
552 | P_MSG_FLAG(FIN); | ||
553 | P_MSG_FLAG(SYN); | ||
554 | P_MSG_FLAG(CONFIRM); | ||
555 | P_MSG_FLAG(RST); | ||
556 | P_MSG_FLAG(ERRQUEUE); | ||
557 | P_MSG_FLAG(NOSIGNAL); | ||
558 | P_MSG_FLAG(MORE); | ||
559 | P_MSG_FLAG(WAITFORONE); | ||
560 | P_MSG_FLAG(SENDPAGE_NOTLAST); | ||
561 | P_MSG_FLAG(FASTOPEN); | ||
562 | P_MSG_FLAG(CMSG_CLOEXEC); | ||
563 | #undef P_MSG_FLAG | ||
564 | |||
565 | if (flags) | ||
566 | printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); | ||
567 | |||
568 | return printed; | ||
569 | } | ||
570 | |||
571 | #define SCA_MSG_FLAGS syscall_arg__scnprintf_msg_flags | ||
572 | |||
573 | static size_t syscall_arg__scnprintf_access_mode(char *bf, size_t size, | 512 | static size_t syscall_arg__scnprintf_access_mode(char *bf, size_t size, |
574 | struct syscall_arg *arg) | 513 | struct syscall_arg *arg) |
575 | { | 514 | { |
@@ -850,6 +789,7 @@ static size_t syscall_arg__scnprintf_getrandom_flags(char *bf, size_t size, | |||
850 | #include "trace/beauty/pid.c" | 789 | #include "trace/beauty/pid.c" |
851 | #include "trace/beauty/mmap.c" | 790 | #include "trace/beauty/mmap.c" |
852 | #include "trace/beauty/mode_t.c" | 791 | #include "trace/beauty/mode_t.c" |
792 | #include "trace/beauty/msg_flags.c" | ||
853 | #include "trace/beauty/perf_event_open.c" | 793 | #include "trace/beauty/perf_event_open.c" |
854 | #include "trace/beauty/sched_policy.c" | 794 | #include "trace/beauty/sched_policy.c" |
855 | #include "trace/beauty/socket_type.c" | 795 | #include "trace/beauty/socket_type.c" |
diff --git a/tools/perf/trace/beauty/msg_flags.c b/tools/perf/trace/beauty/msg_flags.c new file mode 100644 index 000000000000..07fa8a0acad6 --- /dev/null +++ b/tools/perf/trace/beauty/msg_flags.c | |||
@@ -0,0 +1,62 @@ | |||
1 | #include <sys/types.h> | ||
2 | #include <sys/socket.h> | ||
3 | |||
4 | #ifndef MSG_PROBE | ||
5 | #define MSG_PROBE 0x10 | ||
6 | #endif | ||
7 | #ifndef MSG_WAITFORONE | ||
8 | #define MSG_WAITFORONE 0x10000 | ||
9 | #endif | ||
10 | #ifndef MSG_SENDPAGE_NOTLAST | ||
11 | #define MSG_SENDPAGE_NOTLAST 0x20000 | ||
12 | #endif | ||
13 | #ifndef MSG_FASTOPEN | ||
14 | #define MSG_FASTOPEN 0x20000000 | ||
15 | #endif | ||
16 | #ifndef MSG_CMSG_CLOEXEC | ||
17 | # define MSG_CMSG_CLOEXEC 0x40000000 | ||
18 | #endif | ||
19 | |||
20 | static size_t syscall_arg__scnprintf_msg_flags(char *bf, size_t size, | ||
21 | struct syscall_arg *arg) | ||
22 | { | ||
23 | int printed = 0, flags = arg->val; | ||
24 | |||
25 | if (flags == 0) | ||
26 | return scnprintf(bf, size, "NONE"); | ||
27 | #define P_MSG_FLAG(n) \ | ||
28 | if (flags & MSG_##n) { \ | ||
29 | printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ | ||
30 | flags &= ~MSG_##n; \ | ||
31 | } | ||
32 | |||
33 | P_MSG_FLAG(OOB); | ||
34 | P_MSG_FLAG(PEEK); | ||
35 | P_MSG_FLAG(DONTROUTE); | ||
36 | P_MSG_FLAG(TRYHARD); | ||
37 | P_MSG_FLAG(CTRUNC); | ||
38 | P_MSG_FLAG(PROBE); | ||
39 | P_MSG_FLAG(TRUNC); | ||
40 | P_MSG_FLAG(DONTWAIT); | ||
41 | P_MSG_FLAG(EOR); | ||
42 | P_MSG_FLAG(WAITALL); | ||
43 | P_MSG_FLAG(FIN); | ||
44 | P_MSG_FLAG(SYN); | ||
45 | P_MSG_FLAG(CONFIRM); | ||
46 | P_MSG_FLAG(RST); | ||
47 | P_MSG_FLAG(ERRQUEUE); | ||
48 | P_MSG_FLAG(NOSIGNAL); | ||
49 | P_MSG_FLAG(MORE); | ||
50 | P_MSG_FLAG(WAITFORONE); | ||
51 | P_MSG_FLAG(SENDPAGE_NOTLAST); | ||
52 | P_MSG_FLAG(FASTOPEN); | ||
53 | P_MSG_FLAG(CMSG_CLOEXEC); | ||
54 | #undef P_MSG_FLAG | ||
55 | |||
56 | if (flags) | ||
57 | printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); | ||
58 | |||
59 | return printed; | ||
60 | } | ||
61 | |||
62 | #define SCA_MSG_FLAGS syscall_arg__scnprintf_msg_flags | ||