diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-10-31 10:30:09 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-10-31 15:17:03 -0400 |
commit | 0a2f7540abc08e32f89ff273506eeeeb6910794f (patch) | |
tree | edc6a920999dd3e38687fbebf2f28c9a8c69e18e /tools | |
parent | 735e215e95e53b857000aaabe1b4707878b10f43 (diff) |
perf trace beauty: Implement pid_fd beautifier
One that given a pid and a fd, will try to get the path for that fd.
Will be used in the upcoming kcmp's KCMP_FILE beautifier.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andrey Vagin <avagin@openvz.org>
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
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-7ketygp2dvs9h13wuakfncws@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-trace.c | 17 | ||||
-rw-r--r-- | tools/perf/trace/beauty/beauty.h | 3 |
2 files changed, 20 insertions, 0 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index c373f9a3e4a9..0c1461416ef1 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -988,6 +988,23 @@ size_t syscall_arg__scnprintf_fd(char *bf, size_t size, struct syscall_arg *arg) | |||
988 | return printed; | 988 | return printed; |
989 | } | 989 | } |
990 | 990 | ||
991 | size_t pid__scnprintf_fd(struct trace *trace, pid_t pid, int fd, char *bf, size_t size) | ||
992 | { | ||
993 | size_t printed = scnprintf(bf, size, "%d", fd); | ||
994 | struct thread *thread = machine__find_thread(trace->host, pid, pid); | ||
995 | |||
996 | if (thread) { | ||
997 | const char *path = thread__fd_path(thread, fd, trace); | ||
998 | |||
999 | if (path) | ||
1000 | printed += scnprintf(bf + printed, size - printed, "<%s>", path); | ||
1001 | |||
1002 | thread__put(thread); | ||
1003 | } | ||
1004 | |||
1005 | return printed; | ||
1006 | } | ||
1007 | |||
991 | static size_t syscall_arg__scnprintf_close_fd(char *bf, size_t size, | 1008 | static size_t syscall_arg__scnprintf_close_fd(char *bf, size_t size, |
992 | struct syscall_arg *arg) | 1009 | struct syscall_arg *arg) |
993 | { | 1010 | { |
diff --git a/tools/perf/trace/beauty/beauty.h b/tools/perf/trace/beauty/beauty.h index b29f94ef5d6a..365bb6fecc1c 100644 --- a/tools/perf/trace/beauty/beauty.h +++ b/tools/perf/trace/beauty/beauty.h | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | #include <linux/kernel.h> | 4 | #include <linux/kernel.h> |
5 | #include <linux/types.h> | 5 | #include <linux/types.h> |
6 | #include <sys/types.h> | ||
6 | 7 | ||
7 | struct strarray { | 8 | struct strarray { |
8 | int offset; | 9 | int offset; |
@@ -26,6 +27,8 @@ size_t strarray__scnprintf(struct strarray *sa, char *bf, size_t size, const cha | |||
26 | struct trace; | 27 | struct trace; |
27 | struct thread; | 28 | struct thread; |
28 | 29 | ||
30 | size_t pid__scnprintf_fd(struct trace *trace, pid_t pid, int fd, char *bf, size_t size); | ||
31 | |||
29 | /** | 32 | /** |
30 | * @val: value of syscall argument being formatted | 33 | * @val: value of syscall argument being formatted |
31 | * @args: All the args, use syscall_args__val(arg, nth) to access one | 34 | * @args: All the args, use syscall_args__val(arg, nth) to access one |