aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>2016-06-24 05:06:46 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-07-13 22:09:07 -0400
commit40218daea1db1f95f1f10e58ebd43b8adf1c6c61 (patch)
treea3c91dcfa7351c0822d329e0cf93e773b8da728c /tools/perf
parent1de7b8bf728fd8d51b0cc644003d0694c6e0feef (diff)
perf list: Show SDT and pre-cached events
Show SDT and pre-cached events by perf-list with "sdt". This also shows the binary and build-id where the events are placed only when there are same name events on different binaries. e.g.: # perf list sdt List of pre-defined events (to be used in -e): sdt_libc:lll_futex_wake [SDT event] sdt_libc:lll_lock_wait_private [SDT event] sdt_libc:longjmp [SDT event] sdt_libc:longjmp_target [SDT event] ... sdt_libstdcxx:rethrow@/usr/bin/gcc(0cc207fc4b27) [SDT event] sdt_libstdcxx:rethrow@/usr/lib64/libstdc++.so.6.0.20(91c7a88fdf49) sdt_libstdcxx:throw@/usr/bin/gcc(0cc207fc4b27) [SDT event] sdt_libstdcxx:throw@/usr/lib64/libstdc++.so.6.0.20(91c7a88fdf49) The binary path and build-id are shown in below format; <GROUP>:<EVENT>@<PATH>(<BUILD-ID>) Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com> Cc: Brendan Gregg <brendan.d.gregg@gmail.com> Cc: Hemant Kumar <hemant@linux.vnet.ibm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20160624090646.25421.44225.stgit@devbox Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-list.c6
-rw-r--r--tools/perf/util/parse-events.c82
-rw-r--r--tools/perf/util/parse-events.h2
-rw-r--r--tools/perf/util/probe-file.h9
4 files changed, 98 insertions, 1 deletions
diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index 5e22db4684b8..88ee419e5189 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -25,7 +25,7 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
25 OPT_END() 25 OPT_END()
26 }; 26 };
27 const char * const list_usage[] = { 27 const char * const list_usage[] = {
28 "perf list [hw|sw|cache|tracepoint|pmu|event_glob]", 28 "perf list [hw|sw|cache|tracepoint|pmu|sdt|event_glob]",
29 NULL 29 NULL
30 }; 30 };
31 31
@@ -62,6 +62,8 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
62 print_hwcache_events(NULL, raw_dump); 62 print_hwcache_events(NULL, raw_dump);
63 else if (strcmp(argv[i], "pmu") == 0) 63 else if (strcmp(argv[i], "pmu") == 0)
64 print_pmu_events(NULL, raw_dump); 64 print_pmu_events(NULL, raw_dump);
65 else if (strcmp(argv[i], "sdt") == 0)
66 print_sdt_events(NULL, NULL, raw_dump);
65 else if ((sep = strchr(argv[i], ':')) != NULL) { 67 else if ((sep = strchr(argv[i], ':')) != NULL) {
66 int sep_idx; 68 int sep_idx;
67 69
@@ -76,6 +78,7 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
76 78
77 s[sep_idx] = '\0'; 79 s[sep_idx] = '\0';
78 print_tracepoint_events(s, s + sep_idx + 1, raw_dump); 80 print_tracepoint_events(s, s + sep_idx + 1, raw_dump);
81 print_sdt_events(s, s + sep_idx + 1, raw_dump);
79 free(s); 82 free(s);
80 } else { 83 } else {
81 if (asprintf(&s, "*%s*", argv[i]) < 0) { 84 if (asprintf(&s, "*%s*", argv[i]) < 0) {
@@ -89,6 +92,7 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
89 print_hwcache_events(s, raw_dump); 92 print_hwcache_events(s, raw_dump);
90 print_pmu_events(s, raw_dump); 93 print_pmu_events(s, raw_dump);
91 print_tracepoint_events(NULL, s, raw_dump); 94 print_tracepoint_events(NULL, s, raw_dump);
95 print_sdt_events(NULL, s, raw_dump);
92 free(s); 96 free(s);
93 } 97 }
94 } 98 }
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 6b4fff375d99..375af0e02831 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -20,6 +20,7 @@
20#include "pmu.h" 20#include "pmu.h"
21#include "thread_map.h" 21#include "thread_map.h"
22#include "cpumap.h" 22#include "cpumap.h"
23#include "probe-file.h"
23#include "asm/bug.h" 24#include "asm/bug.h"
24 25
25#define MAX_NAME_LEN 100 26#define MAX_NAME_LEN 100
@@ -1984,6 +1985,85 @@ static bool is_event_supported(u8 type, unsigned config)
1984 return ret; 1985 return ret;
1985} 1986}
1986 1987
1988void print_sdt_events(const char *subsys_glob, const char *event_glob,
1989 bool name_only)
1990{
1991 struct probe_cache *pcache;
1992 struct probe_cache_entry *ent;
1993 struct strlist *bidlist, *sdtlist;
1994 struct strlist_config cfg = {.dont_dupstr = true};
1995 struct str_node *nd, *nd2;
1996 char *buf, *path, *ptr = NULL;
1997 bool show_detail = false;
1998 int ret;
1999
2000 sdtlist = strlist__new(NULL, &cfg);
2001 if (!sdtlist) {
2002 pr_debug("Failed to allocate new strlist for SDT\n");
2003 return;
2004 }
2005 bidlist = build_id_cache__list_all(true);
2006 if (!bidlist) {
2007 pr_debug("Failed to get buildids: %d\n", errno);
2008 return;
2009 }
2010 strlist__for_each_entry(nd, bidlist) {
2011 pcache = probe_cache__new(nd->s);
2012 if (!pcache)
2013 continue;
2014 list_for_each_entry(ent, &pcache->entries, node) {
2015 if (!ent->sdt)
2016 continue;
2017 if (subsys_glob &&
2018 !strglobmatch(ent->pev.group, subsys_glob))
2019 continue;
2020 if (event_glob &&
2021 !strglobmatch(ent->pev.event, event_glob))
2022 continue;
2023 ret = asprintf(&buf, "%s:%s@%s", ent->pev.group,
2024 ent->pev.event, nd->s);
2025 if (ret > 0)
2026 strlist__add(sdtlist, buf);
2027 }
2028 probe_cache__delete(pcache);
2029 }
2030 strlist__delete(bidlist);
2031
2032 strlist__for_each_entry(nd, sdtlist) {
2033 buf = strchr(nd->s, '@');
2034 if (buf)
2035 *(buf++) = '\0';
2036 if (name_only) {
2037 printf("%s ", nd->s);
2038 continue;
2039 }
2040 nd2 = strlist__next(nd);
2041 if (nd2) {
2042 ptr = strchr(nd2->s, '@');
2043 if (ptr)
2044 *ptr = '\0';
2045 if (strcmp(nd->s, nd2->s) == 0)
2046 show_detail = true;
2047 }
2048 if (show_detail) {
2049 path = build_id_cache__origname(buf);
2050 ret = asprintf(&buf, "%s@%s(%.12s)", nd->s, path, buf);
2051 if (ret > 0) {
2052 printf(" %-50s [%s]\n", buf, "SDT event");
2053 free(buf);
2054 }
2055 } else
2056 printf(" %-50s [%s]\n", nd->s, "SDT event");
2057 if (nd2) {
2058 if (strcmp(nd->s, nd2->s) != 0)
2059 show_detail = false;
2060 if (ptr)
2061 *ptr = '@';
2062 }
2063 }
2064 strlist__delete(sdtlist);
2065}
2066
1987int print_hwcache_events(const char *event_glob, bool name_only) 2067int print_hwcache_events(const char *event_glob, bool name_only)
1988{ 2068{
1989 unsigned int type, op, i, evt_i = 0, evt_num = 0; 2069 unsigned int type, op, i, evt_i = 0, evt_num = 0;
@@ -2166,6 +2246,8 @@ void print_events(const char *event_glob, bool name_only)
2166 } 2246 }
2167 2247
2168 print_tracepoint_events(NULL, NULL, name_only); 2248 print_tracepoint_events(NULL, NULL, name_only);
2249
2250 print_sdt_events(NULL, NULL, name_only);
2169} 2251}
2170 2252
2171int parse_events__is_hardcoded_term(struct parse_events_term *term) 2253int parse_events__is_hardcoded_term(struct parse_events_term *term)
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index 0bd664dfa53c..b4aa7eb2df73 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -183,6 +183,8 @@ void print_symbol_events(const char *event_glob, unsigned type,
183void print_tracepoint_events(const char *subsys_glob, const char *event_glob, 183void print_tracepoint_events(const char *subsys_glob, const char *event_glob,
184 bool name_only); 184 bool name_only);
185int print_hwcache_events(const char *event_glob, bool name_only); 185int print_hwcache_events(const char *event_glob, bool name_only);
186void print_sdt_events(const char *subsys_glob, const char *event_glob,
187 bool name_only);
186int is_valid_tracepoint(const char *event_string); 188int is_valid_tracepoint(const char *event_string);
187 189
188int valid_event_mount(const char *eventfs); 190int valid_event_mount(const char *eventfs);
diff --git a/tools/perf/util/probe-file.h b/tools/perf/util/probe-file.h
index cafbe1d3f3bf..9577b5c0b487 100644
--- a/tools/perf/util/probe-file.h
+++ b/tools/perf/util/probe-file.h
@@ -24,6 +24,8 @@ struct probe_cache {
24#define for_each_probe_cache_entry(entry, pcache) \ 24#define for_each_probe_cache_entry(entry, pcache) \
25 list_for_each_entry(entry, &pcache->entries, node) 25 list_for_each_entry(entry, &pcache->entries, node)
26 26
27/* probe-file.c depends on libelf */
28#ifdef HAVE_LIBELF_SUPPORT
27int probe_file__open(int flag); 29int probe_file__open(int flag);
28int probe_file__open_both(int *kfd, int *ufd, int flag); 30int probe_file__open_both(int *kfd, int *ufd, int flag);
29struct strlist *probe_file__get_namelist(int fd); 31struct strlist *probe_file__get_namelist(int fd);
@@ -52,4 +54,11 @@ struct probe_cache_entry *probe_cache__find(struct probe_cache *pcache,
52struct probe_cache_entry *probe_cache__find_by_name(struct probe_cache *pcache, 54struct probe_cache_entry *probe_cache__find_by_name(struct probe_cache *pcache,
53 const char *group, const char *event); 55 const char *group, const char *event);
54int probe_cache__show_all_caches(struct strfilter *filter); 56int probe_cache__show_all_caches(struct strfilter *filter);
57#else /* ! HAVE_LIBELF_SUPPORT */
58static inline struct probe_cache *probe_cache__new(const char *tgt __maybe_unused)
59{
60 return NULL;
61}
62#define probe_cache__delete(pcache) do {} while (0)
63#endif
55#endif 64#endif