diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-04-14 12:53:10 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-04-14 12:53:10 -0400 |
commit | bbf86c43eace367e805199f94ad8b5a45636f805 (patch) | |
tree | 592735ad8552df78f5e09d09e5097da02d7b3ee4 /tools/perf | |
parent | 0b22cd276cec21107d9d69453fa58abba73e71df (diff) |
perf trace: Move socket_type 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-ao91htwxdqwlwxr47gbluou1@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-trace.c | 60 | ||||
-rw-r--r-- | tools/perf/trace/beauty/socket_type.c | 60 |
2 files changed, 61 insertions, 59 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 8e090a785c5e..e5f0cc16bb93 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -51,18 +51,6 @@ | |||
51 | # define O_CLOEXEC 02000000 | 51 | # define O_CLOEXEC 02000000 |
52 | #endif | 52 | #endif |
53 | 53 | ||
54 | #ifndef SOCK_DCCP | ||
55 | # define SOCK_DCCP 6 | ||
56 | #endif | ||
57 | |||
58 | #ifndef SOCK_CLOEXEC | ||
59 | # define SOCK_CLOEXEC 02000000 | ||
60 | #endif | ||
61 | |||
62 | #ifndef SOCK_NONBLOCK | ||
63 | # define SOCK_NONBLOCK 00004000 | ||
64 | #endif | ||
65 | |||
66 | #ifndef MSG_CMSG_CLOEXEC | 54 | #ifndef MSG_CMSG_CLOEXEC |
67 | # define MSG_CMSG_CLOEXEC 0x40000000 | 55 | # define MSG_CMSG_CLOEXEC 0x40000000 |
68 | #endif | 56 | #endif |
@@ -538,53 +526,6 @@ static const char *socket_families[] = { | |||
538 | }; | 526 | }; |
539 | static DEFINE_STRARRAY(socket_families); | 527 | static DEFINE_STRARRAY(socket_families); |
540 | 528 | ||
541 | #ifndef SOCK_TYPE_MASK | ||
542 | #define SOCK_TYPE_MASK 0xf | ||
543 | #endif | ||
544 | |||
545 | static size_t syscall_arg__scnprintf_socket_type(char *bf, size_t size, | ||
546 | struct syscall_arg *arg) | ||
547 | { | ||
548 | size_t printed; | ||
549 | int type = arg->val, | ||
550 | flags = type & ~SOCK_TYPE_MASK; | ||
551 | |||
552 | type &= SOCK_TYPE_MASK; | ||
553 | /* | ||
554 | * Can't use a strarray, MIPS may override for ABI reasons. | ||
555 | */ | ||
556 | switch (type) { | ||
557 | #define P_SK_TYPE(n) case SOCK_##n: printed = scnprintf(bf, size, #n); break; | ||
558 | P_SK_TYPE(STREAM); | ||
559 | P_SK_TYPE(DGRAM); | ||
560 | P_SK_TYPE(RAW); | ||
561 | P_SK_TYPE(RDM); | ||
562 | P_SK_TYPE(SEQPACKET); | ||
563 | P_SK_TYPE(DCCP); | ||
564 | P_SK_TYPE(PACKET); | ||
565 | #undef P_SK_TYPE | ||
566 | default: | ||
567 | printed = scnprintf(bf, size, "%#x", type); | ||
568 | } | ||
569 | |||
570 | #define P_SK_FLAG(n) \ | ||
571 | if (flags & SOCK_##n) { \ | ||
572 | printed += scnprintf(bf + printed, size - printed, "|%s", #n); \ | ||
573 | flags &= ~SOCK_##n; \ | ||
574 | } | ||
575 | |||
576 | P_SK_FLAG(CLOEXEC); | ||
577 | P_SK_FLAG(NONBLOCK); | ||
578 | #undef P_SK_FLAG | ||
579 | |||
580 | if (flags) | ||
581 | printed += scnprintf(bf + printed, size - printed, "|%#x", flags); | ||
582 | |||
583 | return printed; | ||
584 | } | ||
585 | |||
586 | #define SCA_SK_TYPE syscall_arg__scnprintf_socket_type | ||
587 | |||
588 | #ifndef MSG_PROBE | 529 | #ifndef MSG_PROBE |
589 | #define MSG_PROBE 0x10 | 530 | #define MSG_PROBE 0x10 |
590 | #endif | 531 | #endif |
@@ -951,6 +892,7 @@ static size_t syscall_arg__scnprintf_getrandom_flags(char *bf, size_t size, | |||
951 | #include "trace/beauty/mmap.c" | 892 | #include "trace/beauty/mmap.c" |
952 | #include "trace/beauty/mode_t.c" | 893 | #include "trace/beauty/mode_t.c" |
953 | #include "trace/beauty/sched_policy.c" | 894 | #include "trace/beauty/sched_policy.c" |
895 | #include "trace/beauty/socket_type.c" | ||
954 | #include "trace/beauty/waitid_options.c" | 896 | #include "trace/beauty/waitid_options.c" |
955 | 897 | ||
956 | static struct syscall_fmt { | 898 | static struct syscall_fmt { |
diff --git a/tools/perf/trace/beauty/socket_type.c b/tools/perf/trace/beauty/socket_type.c new file mode 100644 index 000000000000..0a5ce818131c --- /dev/null +++ b/tools/perf/trace/beauty/socket_type.c | |||
@@ -0,0 +1,60 @@ | |||
1 | #include <sys/types.h> | ||
2 | #include <sys/socket.h> | ||
3 | |||
4 | #ifndef SOCK_DCCP | ||
5 | # define SOCK_DCCP 6 | ||
6 | #endif | ||
7 | |||
8 | #ifndef SOCK_CLOEXEC | ||
9 | # define SOCK_CLOEXEC 02000000 | ||
10 | #endif | ||
11 | |||
12 | #ifndef SOCK_NONBLOCK | ||
13 | # define SOCK_NONBLOCK 00004000 | ||
14 | #endif | ||
15 | |||
16 | #ifndef SOCK_TYPE_MASK | ||
17 | #define SOCK_TYPE_MASK 0xf | ||
18 | #endif | ||
19 | |||
20 | static size_t syscall_arg__scnprintf_socket_type(char *bf, size_t size, struct syscall_arg *arg) | ||
21 | { | ||
22 | size_t printed; | ||
23 | int type = arg->val, | ||
24 | flags = type & ~SOCK_TYPE_MASK; | ||
25 | |||
26 | type &= SOCK_TYPE_MASK; | ||
27 | /* | ||
28 | * Can't use a strarray, MIPS may override for ABI reasons. | ||
29 | */ | ||
30 | switch (type) { | ||
31 | #define P_SK_TYPE(n) case SOCK_##n: printed = scnprintf(bf, size, #n); break; | ||
32 | P_SK_TYPE(STREAM); | ||
33 | P_SK_TYPE(DGRAM); | ||
34 | P_SK_TYPE(RAW); | ||
35 | P_SK_TYPE(RDM); | ||
36 | P_SK_TYPE(SEQPACKET); | ||
37 | P_SK_TYPE(DCCP); | ||
38 | P_SK_TYPE(PACKET); | ||
39 | #undef P_SK_TYPE | ||
40 | default: | ||
41 | printed = scnprintf(bf, size, "%#x", type); | ||
42 | } | ||
43 | |||
44 | #define P_SK_FLAG(n) \ | ||
45 | if (flags & SOCK_##n) { \ | ||
46 | printed += scnprintf(bf + printed, size - printed, "|%s", #n); \ | ||
47 | flags &= ~SOCK_##n; \ | ||
48 | } | ||
49 | |||
50 | P_SK_FLAG(CLOEXEC); | ||
51 | P_SK_FLAG(NONBLOCK); | ||
52 | #undef P_SK_FLAG | ||
53 | |||
54 | if (flags) | ||
55 | printed += scnprintf(bf + printed, size - printed, "|%#x", flags); | ||
56 | |||
57 | return printed; | ||
58 | } | ||
59 | |||
60 | #define SCA_SK_TYPE syscall_arg__scnprintf_socket_type | ||