aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2016-05-23 11:59:53 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-05-23 15:41:00 -0400
commitb6565c908ad7eb28dfdda9578ec5a074e080cedc (patch)
treed9c7d14dae37f46d8bcfc6a86787797f07945733
parent508be0dfe6287d4e6452f5a1dc08856df74cb217 (diff)
perf trace: Use the fd->name beautifier as default for "fd" args
Noticed when the 'setsockopt' 'fd' arg wasn't being formatted via the SCA_FD beautifier, so just remove the setting of "fd" args to SCA_FD and do it when reading the syscall info, like we do for args of type "pid_t", i.e. "fd" as the name should be enough as the decision to use the SFA_FD beautifier. For odd cases we can just do it explicitely. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Milian Wolff <milian.wolff@kdab.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/n/tip-0qissgetiuqmqyj4b6ancmpn@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/builtin-trace.c132
1 files changed, 54 insertions, 78 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 487c10401d46..181f69cd6a8e 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -595,65 +595,45 @@ static struct syscall_fmt {
595 { .name = "connect", .errmsg = true, }, 595 { .name = "connect", .errmsg = true, },
596 { .name = "creat", .errmsg = true, 596 { .name = "creat", .errmsg = true,
597 .arg_scnprintf = { [0] = SCA_FILENAME, /* pathname */ }, }, 597 .arg_scnprintf = { [0] = SCA_FILENAME, /* pathname */ }, },
598 { .name = "dup", .errmsg = true, 598 { .name = "dup", .errmsg = true, },
599 .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, }, 599 { .name = "dup2", .errmsg = true, },
600 { .name = "dup2", .errmsg = true, 600 { .name = "dup3", .errmsg = true, },
601 .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
602 { .name = "dup3", .errmsg = true,
603 .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
604 { .name = "epoll_ctl", .errmsg = true, STRARRAY(1, op, epoll_ctl_ops), }, 601 { .name = "epoll_ctl", .errmsg = true, STRARRAY(1, op, epoll_ctl_ops), },
605 { .name = "eventfd2", .errmsg = true, 602 { .name = "eventfd2", .errmsg = true,
606 .arg_scnprintf = { [1] = SCA_EFD_FLAGS, /* flags */ }, }, 603 .arg_scnprintf = { [1] = SCA_EFD_FLAGS, /* flags */ }, },
607 { .name = "faccessat", .errmsg = true, 604 { .name = "faccessat", .errmsg = true,
608 .arg_scnprintf = { [0] = SCA_FDAT, /* dfd */ 605 .arg_scnprintf = { [1] = SCA_FILENAME, /* filename */ }, },
609 [1] = SCA_FILENAME, /* filename */ }, }, 606 { .name = "fadvise64", .errmsg = true, },
610 { .name = "fadvise64", .errmsg = true, 607 { .name = "fallocate", .errmsg = true, },
611 .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, }, 608 { .name = "fchdir", .errmsg = true, },
612 { .name = "fallocate", .errmsg = true, 609 { .name = "fchmod", .errmsg = true, },
613 .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
614 { .name = "fchdir", .errmsg = true,
615 .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
616 { .name = "fchmod", .errmsg = true,
617 .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
618 { .name = "fchmodat", .errmsg = true, 610 { .name = "fchmodat", .errmsg = true,
619 .arg_scnprintf = { [0] = SCA_FDAT, /* fd */ 611 .arg_scnprintf = { [0] = SCA_FDAT, /* fd */
620 [1] = SCA_FILENAME, /* filename */ }, }, 612 [1] = SCA_FILENAME, /* filename */ }, },
621 { .name = "fchown", .errmsg = true, 613 { .name = "fchown", .errmsg = true, },
622 .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
623 { .name = "fchownat", .errmsg = true, 614 { .name = "fchownat", .errmsg = true,
624 .arg_scnprintf = { [0] = SCA_FDAT, /* fd */ 615 .arg_scnprintf = { [0] = SCA_FDAT, /* fd */
625 [1] = SCA_FILENAME, /* filename */ }, }, 616 [1] = SCA_FILENAME, /* filename */ }, },
626 { .name = "fcntl", .errmsg = true, 617 { .name = "fcntl", .errmsg = true,
627 .arg_scnprintf = { [0] = SCA_FD, /* fd */ 618 .arg_scnprintf = { [1] = SCA_STRARRAY, /* cmd */ },
628 [1] = SCA_STRARRAY, /* cmd */ },
629 .arg_parm = { [1] = &strarray__fcntl_cmds, /* cmd */ }, }, 619 .arg_parm = { [1] = &strarray__fcntl_cmds, /* cmd */ }, },
630 { .name = "fdatasync", .errmsg = true, 620 { .name = "fdatasync", .errmsg = true, },
631 .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
632 { .name = "flock", .errmsg = true, 621 { .name = "flock", .errmsg = true,
633 .arg_scnprintf = { [0] = SCA_FD, /* fd */ 622 .arg_scnprintf = { [1] = SCA_FLOCK, /* cmd */ }, },
634 [1] = SCA_FLOCK, /* cmd */ }, }, 623 { .name = "fsetxattr", .errmsg = true, },
635 { .name = "fsetxattr", .errmsg = true, 624 { .name = "fstat", .errmsg = true, .alias = "newfstat", },
636 .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
637 { .name = "fstat", .errmsg = true, .alias = "newfstat",
638 .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
639 { .name = "fstatat", .errmsg = true, .alias = "newfstatat", 625 { .name = "fstatat", .errmsg = true, .alias = "newfstatat",
640 .arg_scnprintf = { [0] = SCA_FDAT, /* dfd */ 626 .arg_scnprintf = { [1] = SCA_FILENAME, /* filename */ }, },
641 [1] = SCA_FILENAME, /* filename */ }, }, 627 { .name = "fstatfs", .errmsg = true, },
642 { .name = "fstatfs", .errmsg = true, 628 { .name = "fsync", .errmsg = true, },
643 .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, }, 629 { .name = "ftruncate", .errmsg = true, },
644 { .name = "fsync", .errmsg = true,
645 .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
646 { .name = "ftruncate", .errmsg = true,
647 .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
648 { .name = "futex", .errmsg = true, 630 { .name = "futex", .errmsg = true,
649 .arg_scnprintf = { [1] = SCA_FUTEX_OP, /* op */ }, }, 631 .arg_scnprintf = { [1] = SCA_FUTEX_OP, /* op */ }, },
650 { .name = "futimesat", .errmsg = true, 632 { .name = "futimesat", .errmsg = true,
651 .arg_scnprintf = { [0] = SCA_FDAT, /* fd */ 633 .arg_scnprintf = { [0] = SCA_FDAT, /* fd */
652 [1] = SCA_FILENAME, /* filename */ }, }, 634 [1] = SCA_FILENAME, /* filename */ }, },
653 { .name = "getdents", .errmsg = true, 635 { .name = "getdents", .errmsg = true, },
654 .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, }, 636 { .name = "getdents64", .errmsg = true, },
655 { .name = "getdents64", .errmsg = true,
656 .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
657 { .name = "getitimer", .errmsg = true, STRARRAY(0, which, itimers), }, 637 { .name = "getitimer", .errmsg = true, STRARRAY(0, which, itimers), },
658 { .name = "getpid", .errpid = true, }, 638 { .name = "getpid", .errpid = true, },
659 { .name = "getpgid", .errpid = true, }, 639 { .name = "getpgid", .errpid = true, },
@@ -666,7 +646,7 @@ static struct syscall_fmt {
666 { .name = "inotify_add_watch", .errmsg = true, 646 { .name = "inotify_add_watch", .errmsg = true,
667 .arg_scnprintf = { [1] = SCA_FILENAME, /* pathname */ }, }, 647 .arg_scnprintf = { [1] = SCA_FILENAME, /* pathname */ }, },
668 { .name = "ioctl", .errmsg = true, 648 { .name = "ioctl", .errmsg = true,
669 .arg_scnprintf = { [0] = SCA_FD, /* fd */ 649 .arg_scnprintf = {
670#if defined(__i386__) || defined(__x86_64__) 650#if defined(__i386__) || defined(__x86_64__)
671/* 651/*
672 * FIXME: Make this available to all arches. 652 * FIXME: Make this available to all arches.
@@ -693,8 +673,7 @@ static struct syscall_fmt {
693 { .name = "lremovexattr", .errmsg = true, 673 { .name = "lremovexattr", .errmsg = true,
694 .arg_scnprintf = { [0] = SCA_FILENAME, /* pathname */ }, }, 674 .arg_scnprintf = { [0] = SCA_FILENAME, /* pathname */ }, },
695 { .name = "lseek", .errmsg = true, 675 { .name = "lseek", .errmsg = true,
696 .arg_scnprintf = { [0] = SCA_FD, /* fd */ 676 .arg_scnprintf = { [2] = SCA_STRARRAY, /* whence */ },
697 [2] = SCA_STRARRAY, /* whence */ },
698 .arg_parm = { [2] = &strarray__whences, /* whence */ }, }, 677 .arg_parm = { [2] = &strarray__whences, /* whence */ }, },
699 { .name = "lsetxattr", .errmsg = true, 678 { .name = "lsetxattr", .errmsg = true,
700 .arg_scnprintf = { [0] = SCA_FILENAME, /* pathname */ }, }, 679 .arg_scnprintf = { [0] = SCA_FILENAME, /* pathname */ }, },
@@ -722,8 +701,7 @@ static struct syscall_fmt {
722 { .name = "mmap", .hexret = true, 701 { .name = "mmap", .hexret = true,
723 .arg_scnprintf = { [0] = SCA_HEX, /* addr */ 702 .arg_scnprintf = { [0] = SCA_HEX, /* addr */
724 [2] = SCA_MMAP_PROT, /* prot */ 703 [2] = SCA_MMAP_PROT, /* prot */
725 [3] = SCA_MMAP_FLAGS, /* flags */ 704 [3] = SCA_MMAP_FLAGS, /* flags */ }, },
726 [4] = SCA_FD, /* fd */ }, },
727 { .name = "mprotect", .errmsg = true, 705 { .name = "mprotect", .errmsg = true,
728 .arg_scnprintf = { [0] = SCA_HEX, /* start */ 706 .arg_scnprintf = { [0] = SCA_HEX, /* start */
729 [2] = SCA_MMAP_PROT, /* prot */ }, }, 707 [2] = SCA_MMAP_PROT, /* prot */ }, },
@@ -760,33 +738,24 @@ static struct syscall_fmt {
760 .arg_scnprintf = { [1] = SCA_PIPE_FLAGS, /* flags */ }, }, 738 .arg_scnprintf = { [1] = SCA_PIPE_FLAGS, /* flags */ }, },
761 { .name = "poll", .errmsg = true, .timeout = true, }, 739 { .name = "poll", .errmsg = true, .timeout = true, },
762 { .name = "ppoll", .errmsg = true, .timeout = true, }, 740 { .name = "ppoll", .errmsg = true, .timeout = true, },
763 { .name = "pread", .errmsg = true, .alias = "pread64", 741 { .name = "pread", .errmsg = true, .alias = "pread64", },
764 .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, }, 742 { .name = "preadv", .errmsg = true, .alias = "pread", },
765 { .name = "preadv", .errmsg = true, .alias = "pread",
766 .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
767 { .name = "prlimit64", .errmsg = true, STRARRAY(1, resource, rlimit_resources), }, 743 { .name = "prlimit64", .errmsg = true, STRARRAY(1, resource, rlimit_resources), },
768 { .name = "pwrite", .errmsg = true, .alias = "pwrite64", 744 { .name = "pwrite", .errmsg = true, .alias = "pwrite64", },
769 .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, }, 745 { .name = "pwritev", .errmsg = true, },
770 { .name = "pwritev", .errmsg = true, 746 { .name = "read", .errmsg = true, },
771 .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
772 { .name = "read", .errmsg = true,
773 .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
774 { .name = "readlink", .errmsg = true, 747 { .name = "readlink", .errmsg = true,
775 .arg_scnprintf = { [0] = SCA_FILENAME, /* path */ }, }, 748 .arg_scnprintf = { [0] = SCA_FILENAME, /* path */ }, },
776 { .name = "readlinkat", .errmsg = true, 749 { .name = "readlinkat", .errmsg = true,
777 .arg_scnprintf = { [0] = SCA_FDAT, /* dfd */ 750 .arg_scnprintf = { [0] = SCA_FDAT, /* dfd */
778 [1] = SCA_FILENAME, /* pathname */ }, }, 751 [1] = SCA_FILENAME, /* pathname */ }, },
779 { .name = "readv", .errmsg = true, 752 { .name = "readv", .errmsg = true, },
780 .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
781 { .name = "recvfrom", .errmsg = true, 753 { .name = "recvfrom", .errmsg = true,
782 .arg_scnprintf = { [0] = SCA_FD, /* fd */ 754 .arg_scnprintf = { [3] = SCA_MSG_FLAGS, /* flags */ }, },
783 [3] = SCA_MSG_FLAGS, /* flags */ }, },
784 { .name = "recvmmsg", .errmsg = true, 755 { .name = "recvmmsg", .errmsg = true,
785 .arg_scnprintf = { [0] = SCA_FD, /* fd */ 756 .arg_scnprintf = { [3] = SCA_MSG_FLAGS, /* flags */ }, },
786 [3] = SCA_MSG_FLAGS, /* flags */ }, },
787 { .name = "recvmsg", .errmsg = true, 757 { .name = "recvmsg", .errmsg = true,
788 .arg_scnprintf = { [0] = SCA_FD, /* fd */ 758 .arg_scnprintf = { [2] = SCA_MSG_FLAGS, /* flags */ }, },
789 [2] = SCA_MSG_FLAGS, /* flags */ }, },
790 { .name = "removexattr", .errmsg = true, 759 { .name = "removexattr", .errmsg = true,
791 .arg_scnprintf = { [0] = SCA_FILENAME, /* pathname */ }, }, 760 .arg_scnprintf = { [0] = SCA_FILENAME, /* pathname */ }, },
792 { .name = "renameat", .errmsg = true, 761 { .name = "renameat", .errmsg = true,
@@ -807,22 +776,18 @@ static struct syscall_fmt {
807 [1] = SCA_SECCOMP_FLAGS, /* flags */ }, }, 776 [1] = SCA_SECCOMP_FLAGS, /* flags */ }, },
808 { .name = "select", .errmsg = true, .timeout = true, }, 777 { .name = "select", .errmsg = true, .timeout = true, },
809 { .name = "sendmmsg", .errmsg = true, 778 { .name = "sendmmsg", .errmsg = true,
810 .arg_scnprintf = { [0] = SCA_FD, /* fd */ 779 .arg_scnprintf = { [3] = SCA_MSG_FLAGS, /* flags */ }, },
811 [3] = SCA_MSG_FLAGS, /* flags */ }, },
812 { .name = "sendmsg", .errmsg = true, 780 { .name = "sendmsg", .errmsg = true,
813 .arg_scnprintf = { [0] = SCA_FD, /* fd */ 781 .arg_scnprintf = { [2] = SCA_MSG_FLAGS, /* flags */ }, },
814 [2] = SCA_MSG_FLAGS, /* flags */ }, },
815 { .name = "sendto", .errmsg = true, 782 { .name = "sendto", .errmsg = true,
816 .arg_scnprintf = { [0] = SCA_FD, /* fd */ 783 .arg_scnprintf = { [3] = SCA_MSG_FLAGS, /* flags */ }, },
817 [3] = SCA_MSG_FLAGS, /* flags */ }, },
818 { .name = "set_tid_address", .errpid = true, }, 784 { .name = "set_tid_address", .errpid = true, },
819 { .name = "setitimer", .errmsg = true, STRARRAY(0, which, itimers), }, 785 { .name = "setitimer", .errmsg = true, STRARRAY(0, which, itimers), },
820 { .name = "setpgid", .errmsg = true, }, 786 { .name = "setpgid", .errmsg = true, },
821 { .name = "setrlimit", .errmsg = true, STRARRAY(0, resource, rlimit_resources), }, 787 { .name = "setrlimit", .errmsg = true, STRARRAY(0, resource, rlimit_resources), },
822 { .name = "setxattr", .errmsg = true, 788 { .name = "setxattr", .errmsg = true,
823 .arg_scnprintf = { [0] = SCA_FILENAME, /* pathname */ }, }, 789 .arg_scnprintf = { [0] = SCA_FILENAME, /* pathname */ }, },
824 { .name = "shutdown", .errmsg = true, 790 { .name = "shutdown", .errmsg = true, },
825 .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
826 { .name = "socket", .errmsg = true, 791 { .name = "socket", .errmsg = true,
827 .arg_scnprintf = { [0] = SCA_STRARRAY, /* family */ 792 .arg_scnprintf = { [0] = SCA_STRARRAY, /* family */
828 [1] = SCA_SK_TYPE, /* type */ }, 793 [1] = SCA_SK_TYPE, /* type */ },
@@ -858,16 +823,13 @@ static struct syscall_fmt {
858 [1] = SCA_FILENAME, /* filename */ }, }, 823 [1] = SCA_FILENAME, /* filename */ }, },
859 { .name = "utimes", .errmsg = true, 824 { .name = "utimes", .errmsg = true,
860 .arg_scnprintf = { [0] = SCA_FILENAME, /* filename */ }, }, 825 .arg_scnprintf = { [0] = SCA_FILENAME, /* filename */ }, },
861 { .name = "vmsplice", .errmsg = true, 826 { .name = "vmsplice", .errmsg = true, },
862 .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
863 { .name = "wait4", .errpid = true, 827 { .name = "wait4", .errpid = true,
864 .arg_scnprintf = { [2] = SCA_WAITID_OPTIONS, /* options */ }, }, 828 .arg_scnprintf = { [2] = SCA_WAITID_OPTIONS, /* options */ }, },
865 { .name = "waitid", .errpid = true, 829 { .name = "waitid", .errpid = true,
866 .arg_scnprintf = { [3] = SCA_WAITID_OPTIONS, /* options */ }, }, 830 .arg_scnprintf = { [3] = SCA_WAITID_OPTIONS, /* options */ }, },
867 { .name = "write", .errmsg = true, 831 { .name = "write", .errmsg = true, },
868 .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, }, 832 { .name = "writev", .errmsg = true, },
869 { .name = "writev", .errmsg = true,
870 .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
871}; 833};
872 834
873static int syscall_fmt__cmp(const void *name, const void *fmtp) 835static int syscall_fmt__cmp(const void *name, const void *fmtp)
@@ -1204,7 +1166,7 @@ static int trace__symbols_init(struct trace *trace, struct perf_evlist *evlist)
1204static int syscall__set_arg_fmts(struct syscall *sc) 1166static int syscall__set_arg_fmts(struct syscall *sc)
1205{ 1167{
1206 struct format_field *field; 1168 struct format_field *field;
1207 int idx = 0; 1169 int idx = 0, len;
1208 1170
1209 sc->arg_scnprintf = calloc(sc->nr_args, sizeof(void *)); 1171 sc->arg_scnprintf = calloc(sc->nr_args, sizeof(void *));
1210 if (sc->arg_scnprintf == NULL) 1172 if (sc->arg_scnprintf == NULL)
@@ -1222,6 +1184,20 @@ static int syscall__set_arg_fmts(struct syscall *sc)
1222 sc->arg_scnprintf[idx] = SCA_PID; 1184 sc->arg_scnprintf[idx] = SCA_PID;
1223 else if (strcmp(field->type, "umode_t") == 0) 1185 else if (strcmp(field->type, "umode_t") == 0)
1224 sc->arg_scnprintf[idx] = SCA_MODE_T; 1186 sc->arg_scnprintf[idx] = SCA_MODE_T;
1187 else if ((strcmp(field->type, "int") == 0 ||
1188 strcmp(field->type, "unsigned int") == 0 ||
1189 strcmp(field->type, "long") == 0) &&
1190 (len = strlen(field->name)) >= 2 &&
1191 strcmp(field->name + len - 2, "fd") == 0) {
1192 /*
1193 * /sys/kernel/tracing/events/syscalls/sys_enter*
1194 * egrep 'field:.*fd;' .../format|sed -r 's/.*field:([a-z ]+) [a-z_]*fd.+/\1/g'|sort|uniq -c
1195 * 65 int
1196 * 23 unsigned int
1197 * 7 unsigned long
1198 */
1199 sc->arg_scnprintf[idx] = SCA_FD;
1200 }
1225 ++idx; 1201 ++idx;
1226 } 1202 }
1227 1203