diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-05-11 09:32:20 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-05-11 12:06:00 -0400 |
commit | f5cd95ea6082d389be3337bea16c65d4220614fc (patch) | |
tree | 696d064053b31297458ae6e29000bcecdd71f594 /tools/perf | |
parent | 8bf382ce0aef999663bf8d2b02bbfa7da1e9d272 (diff) |
perf trace: Move seccomp args beautifiers to tools/perf/trace/beauty/
To reduce the size of builtin-trace.c.
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/n/tip-ovxifncj34ynrjjseg33lil3@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 | 53 | ||||
-rw-r--r-- | tools/perf/trace/beauty/seccomp.c | 52 |
2 files changed, 53 insertions, 52 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index c330d1a654c4..6e5c325148e4 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -41,7 +41,6 @@ | |||
41 | #include <libaudit.h> /* FIXME: Still needed for audit_errno_to_name */ | 41 | #include <libaudit.h> /* FIXME: Still needed for audit_errno_to_name */ |
42 | #include <stdlib.h> | 42 | #include <stdlib.h> |
43 | #include <linux/err.h> | 43 | #include <linux/err.h> |
44 | #include <linux/seccomp.h> | ||
45 | #include <linux/filter.h> | 44 | #include <linux/filter.h> |
46 | #include <linux/audit.h> | 45 | #include <linux/audit.h> |
47 | #include <sys/ptrace.h> | 46 | #include <sys/ptrace.h> |
@@ -517,57 +516,6 @@ static const char *tioctls[] = { | |||
517 | static DEFINE_STRARRAY_OFFSET(tioctls, 0x5401); | 516 | static DEFINE_STRARRAY_OFFSET(tioctls, 0x5401); |
518 | #endif /* defined(__i386__) || defined(__x86_64__) */ | 517 | #endif /* defined(__i386__) || defined(__x86_64__) */ |
519 | 518 | ||
520 | #ifndef SECCOMP_SET_MODE_STRICT | ||
521 | #define SECCOMP_SET_MODE_STRICT 0 | ||
522 | #endif | ||
523 | #ifndef SECCOMP_SET_MODE_FILTER | ||
524 | #define SECCOMP_SET_MODE_FILTER 1 | ||
525 | #endif | ||
526 | |||
527 | static size_t syscall_arg__scnprintf_seccomp_op(char *bf, size_t size, struct syscall_arg *arg) | ||
528 | { | ||
529 | int op = arg->val; | ||
530 | size_t printed = 0; | ||
531 | |||
532 | switch (op) { | ||
533 | #define P_SECCOMP_SET_MODE_OP(n) case SECCOMP_SET_MODE_##n: printed = scnprintf(bf, size, #n); break | ||
534 | P_SECCOMP_SET_MODE_OP(STRICT); | ||
535 | P_SECCOMP_SET_MODE_OP(FILTER); | ||
536 | #undef P_SECCOMP_SET_MODE_OP | ||
537 | default: printed = scnprintf(bf, size, "%#x", op); break; | ||
538 | } | ||
539 | |||
540 | return printed; | ||
541 | } | ||
542 | |||
543 | #define SCA_SECCOMP_OP syscall_arg__scnprintf_seccomp_op | ||
544 | |||
545 | #ifndef SECCOMP_FILTER_FLAG_TSYNC | ||
546 | #define SECCOMP_FILTER_FLAG_TSYNC 1 | ||
547 | #endif | ||
548 | |||
549 | static size_t syscall_arg__scnprintf_seccomp_flags(char *bf, size_t size, | ||
550 | struct syscall_arg *arg) | ||
551 | { | ||
552 | int printed = 0, flags = arg->val; | ||
553 | |||
554 | #define P_FLAG(n) \ | ||
555 | if (flags & SECCOMP_FILTER_FLAG_##n) { \ | ||
556 | printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ | ||
557 | flags &= ~SECCOMP_FILTER_FLAG_##n; \ | ||
558 | } | ||
559 | |||
560 | P_FLAG(TSYNC); | ||
561 | #undef P_FLAG | ||
562 | |||
563 | if (flags) | ||
564 | printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); | ||
565 | |||
566 | return printed; | ||
567 | } | ||
568 | |||
569 | #define SCA_SECCOMP_FLAGS syscall_arg__scnprintf_seccomp_flags | ||
570 | |||
571 | #ifndef GRND_NONBLOCK | 519 | #ifndef GRND_NONBLOCK |
572 | #define GRND_NONBLOCK 0x0001 | 520 | #define GRND_NONBLOCK 0x0001 |
573 | #endif | 521 | #endif |
@@ -612,6 +560,7 @@ static size_t syscall_arg__scnprintf_getrandom_flags(char *bf, size_t size, | |||
612 | #include "trace/beauty/perf_event_open.c" | 560 | #include "trace/beauty/perf_event_open.c" |
613 | #include "trace/beauty/pid.c" | 561 | #include "trace/beauty/pid.c" |
614 | #include "trace/beauty/sched_policy.c" | 562 | #include "trace/beauty/sched_policy.c" |
563 | #include "trace/beauty/seccomp.c" | ||
615 | #include "trace/beauty/signum.c" | 564 | #include "trace/beauty/signum.c" |
616 | #include "trace/beauty/socket_type.c" | 565 | #include "trace/beauty/socket_type.c" |
617 | #include "trace/beauty/waitid_options.c" | 566 | #include "trace/beauty/waitid_options.c" |
diff --git a/tools/perf/trace/beauty/seccomp.c b/tools/perf/trace/beauty/seccomp.c new file mode 100644 index 000000000000..213c5a7e3e92 --- /dev/null +++ b/tools/perf/trace/beauty/seccomp.c | |||
@@ -0,0 +1,52 @@ | |||
1 | #include <linux/seccomp.h> | ||
2 | |||
3 | #ifndef SECCOMP_SET_MODE_STRICT | ||
4 | #define SECCOMP_SET_MODE_STRICT 0 | ||
5 | #endif | ||
6 | #ifndef SECCOMP_SET_MODE_FILTER | ||
7 | #define SECCOMP_SET_MODE_FILTER 1 | ||
8 | #endif | ||
9 | |||
10 | static size_t syscall_arg__scnprintf_seccomp_op(char *bf, size_t size, struct syscall_arg *arg) | ||
11 | { | ||
12 | int op = arg->val; | ||
13 | size_t printed = 0; | ||
14 | |||
15 | switch (op) { | ||
16 | #define P_SECCOMP_SET_MODE_OP(n) case SECCOMP_SET_MODE_##n: printed = scnprintf(bf, size, #n); break | ||
17 | P_SECCOMP_SET_MODE_OP(STRICT); | ||
18 | P_SECCOMP_SET_MODE_OP(FILTER); | ||
19 | #undef P_SECCOMP_SET_MODE_OP | ||
20 | default: printed = scnprintf(bf, size, "%#x", op); break; | ||
21 | } | ||
22 | |||
23 | return printed; | ||
24 | } | ||
25 | |||
26 | #define SCA_SECCOMP_OP syscall_arg__scnprintf_seccomp_op | ||
27 | |||
28 | #ifndef SECCOMP_FILTER_FLAG_TSYNC | ||
29 | #define SECCOMP_FILTER_FLAG_TSYNC 1 | ||
30 | #endif | ||
31 | |||
32 | static size_t syscall_arg__scnprintf_seccomp_flags(char *bf, size_t size, | ||
33 | struct syscall_arg *arg) | ||
34 | { | ||
35 | int printed = 0, flags = arg->val; | ||
36 | |||
37 | #define P_FLAG(n) \ | ||
38 | if (flags & SECCOMP_FILTER_FLAG_##n) { \ | ||
39 | printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ | ||
40 | flags &= ~SECCOMP_FILTER_FLAG_##n; \ | ||
41 | } | ||
42 | |||
43 | P_FLAG(TSYNC); | ||
44 | #undef P_FLAG | ||
45 | |||
46 | if (flags) | ||
47 | printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); | ||
48 | |||
49 | return printed; | ||
50 | } | ||
51 | |||
52 | #define SCA_SECCOMP_FLAGS syscall_arg__scnprintf_seccomp_flags | ||