|
20 | 20 | #include "pmu.h" |
21 | 21 | #include "thread_map.h" |
22 | 22 | #include "cpumap.h" |
| 23 | +#include "probe-file.h" |
23 | 24 | #include "asm/bug.h" |
24 | 25 |
|
25 | 26 | #define MAX_NAME_LEN 100 |
@@ -1984,6 +1985,85 @@ static bool is_event_supported(u8 type, unsigned config) |
1984 | 1985 | return ret; |
1985 | 1986 | } |
1986 | 1987 |
|
| 1988 | +void 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 | + |
1987 | 2067 | int print_hwcache_events(const char *event_glob, bool name_only) |
1988 | 2068 | { |
1989 | 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 | 2248 | print_tracepoint_events(NULL, NULL, name_only); |
| 2249 | + |
| 2250 | + print_sdt_events(NULL, NULL, name_only); |
2169 | 2251 | } |
2170 | 2252 |
|
2171 | 2253 | int parse_events__is_hardcoded_term(struct parse_events_term *term) |
|
0 commit comments