Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+53 -52
+1 -52
tools/perf/builtin-trace.c
··· 41 41 #include <libaudit.h> /* FIXME: Still needed for audit_errno_to_name */ 42 42 #include <stdlib.h> 43 43 #include <linux/err.h> 44 - #include <linux/seccomp.h> 45 44 #include <linux/filter.h> 46 45 #include <linux/audit.h> 47 46 #include <sys/ptrace.h> ··· 516 517 static DEFINE_STRARRAY_OFFSET(tioctls, 0x5401); 517 518 #endif /* defined(__i386__) || defined(__x86_64__) */ 518 519 519 - #ifndef SECCOMP_SET_MODE_STRICT 520 - #define SECCOMP_SET_MODE_STRICT 0 521 - #endif 522 - #ifndef SECCOMP_SET_MODE_FILTER 523 - #define SECCOMP_SET_MODE_FILTER 1 524 - #endif 525 - 526 - static size_t syscall_arg__scnprintf_seccomp_op(char *bf, size_t size, struct syscall_arg *arg) 527 - { 528 - int op = arg->val; 529 - size_t printed = 0; 530 - 531 - switch (op) { 532 - #define P_SECCOMP_SET_MODE_OP(n) case SECCOMP_SET_MODE_##n: printed = scnprintf(bf, size, #n); break 533 - P_SECCOMP_SET_MODE_OP(STRICT); 534 - P_SECCOMP_SET_MODE_OP(FILTER); 535 - #undef P_SECCOMP_SET_MODE_OP 536 - default: printed = scnprintf(bf, size, "%#x", op); break; 537 - } 538 - 539 - return printed; 540 - } 541 - 542 - #define SCA_SECCOMP_OP syscall_arg__scnprintf_seccomp_op 543 - 544 - #ifndef SECCOMP_FILTER_FLAG_TSYNC 545 - #define SECCOMP_FILTER_FLAG_TSYNC 1 546 - #endif 547 - 548 - static size_t syscall_arg__scnprintf_seccomp_flags(char *bf, size_t size, 549 - struct syscall_arg *arg) 550 - { 551 - int printed = 0, flags = arg->val; 552 - 553 - #define P_FLAG(n) \ 554 - if (flags & SECCOMP_FILTER_FLAG_##n) { \ 555 - printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ 556 - flags &= ~SECCOMP_FILTER_FLAG_##n; \ 557 - } 558 - 559 - P_FLAG(TSYNC); 560 - #undef P_FLAG 561 - 562 - if (flags) 563 - printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); 564 - 565 - return printed; 566 - } 567 - 568 - #define SCA_SECCOMP_FLAGS syscall_arg__scnprintf_seccomp_flags 569 - 570 520 #ifndef GRND_NONBLOCK 571 521 #define GRND_NONBLOCK 0x0001 572 522 #endif ··· 560 612 #include "trace/beauty/perf_event_open.c" 561 613 #include "trace/beauty/pid.c" 562 614 #include "trace/beauty/sched_policy.c" 615 + #include "trace/beauty/seccomp.c" 563 616 #include "trace/beauty/signum.c" 564 617 #include "trace/beauty/socket_type.c" 565 618 #include "trace/beauty/waitid_options.c"
+52
tools/perf/trace/beauty/seccomp.c
··· 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