Skip to content

Commit 35a23ff

Browse files
mhiramathitachiacmel
authored andcommitted
perf probe: Cut off the gcc optimization postfixes from function name
Cut off the postfixes which gcc added for optimized routines from the event name automatically generated from symbol name, since *probe-events doesn't accept it. Those symbols will be used if we don't use debuginfo to find target functions. E.g. without this fix; ----- # perf probe -va alloc_buf.isra.23 probe-definition(0): alloc_buf.isra.23 symbol:alloc_buf.isra.23 file:(null) line:0 offset:0 return:0 lazy:(null) [...] Opening /sys/kernel/debug/tracing/kprobe_events write=1 Added new event: Writing event: p:probe/alloc_buf.isra.23 _text+4869328 Failed to write event: Invalid argument Error: Failed to add events. Reason: Invalid argument (Code: -22) ----- With this fix; ----- perf probe -va alloc_buf.isra.23 probe-definition(0): alloc_buf.isra.23 symbol:alloc_buf.isra.23 file:(null) line:0 offset:0 return:0 lazy:(null) [...] Opening /sys/kernel/debug/tracing/kprobe_events write=1 Added new event: Writing event: p:probe/alloc_buf _text+4869328 probe:alloc_buf (on alloc_buf.isra.23) You can now use it in all perf tools, such as: perf record -e probe:alloc_buf -aR sleep 1 ----- Signed-off-by: Masami Hiramatsu <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: David Ahern <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Naohiro Aota <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 61d67d5 commit 35a23ff

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tools/perf/util/probe-event.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2316,6 +2316,7 @@ static int get_new_event_name(char *buf, size_t len, const char *base,
23162316
struct strlist *namelist, bool allow_suffix)
23172317
{
23182318
int i, ret;
2319+
char *p;
23192320

23202321
if (*base == '.')
23212322
base++;
@@ -2326,6 +2327,10 @@ static int get_new_event_name(char *buf, size_t len, const char *base,
23262327
pr_debug("snprintf() failed: %d\n", ret);
23272328
return ret;
23282329
}
2330+
/* Cut off the postfixes (e.g. .const, .isra)*/
2331+
p = strchr(buf, '.');
2332+
if (p && p != buf)
2333+
*p = '\0';
23292334
if (!strlist__has_entry(namelist, buf))
23302335
return 0;
23312336

0 commit comments

Comments
 (0)