aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2015-03-06 02:31:29 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-03-12 11:39:55 -0400
commite578da3b2009da2a9ae2d25fd0f78c7b76ca5e56 (patch)
tree2feb577135345a0dfe209c9084a7a44b6006400f /tools
parent680d926a8cb08dd9cf173e2bb93d4a4477771949 (diff)
perf probe: Allow weak symbols to be probed
It currently prevents adding probes in weak symbols. But there're cases that given name is an only weak symbol so that we cannot add probe. $ perf probe -x /usr/lib/libc.so.6 -a calloc Failed to find symbol calloc in /usr/lib/libc-2.21.so Error: Failed to add events. $ nm /usr/lib/libc.so.6 | grep calloc 000000000007b1f0 t __calloc 000000000007b1f0 T __libc_calloc 000000000007b1f0 W calloc This change will result in duplicate probes when strong and weak symbols co-exist in a binary. But I think it's not a big problem since probes at the weak symbol will never be hit anyway. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Naohiro Aota <naota@elisp.net> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20150306073129.6904.41078.stgit@localhost.localdomain Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/probe-event.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 9feba0e3343e..8af8e7f55254 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -310,10 +310,8 @@ static int find_alternative_probe_point(struct debuginfo *dinfo,
310 310
311 /* Find the address of given function */ 311 /* Find the address of given function */
312 map__for_each_symbol_by_name(map, pp->function, sym) { 312 map__for_each_symbol_by_name(map, pp->function, sym) {
313 if (sym->binding == STB_GLOBAL || sym->binding == STB_LOCAL) { 313 address = sym->start;
314 address = sym->start; 314 break;
315 break;
316 }
317 } 315 }
318 if (!address) { 316 if (!address) {
319 ret = -ENOENT; 317 ret = -ENOENT;
@@ -2485,8 +2483,7 @@ static int find_probe_functions(struct map *map, char *name)
2485 struct symbol *sym; 2483 struct symbol *sym;
2486 2484
2487 map__for_each_symbol_by_name(map, name, sym) { 2485 map__for_each_symbol_by_name(map, name, sym) {
2488 if (sym->binding == STB_GLOBAL || sym->binding == STB_LOCAL) 2486 found++;
2489 found++;
2490 } 2487 }
2491 2488
2492 return found; 2489 return found;
@@ -2846,8 +2843,7 @@ static struct strfilter *available_func_filter;
2846static int filter_available_functions(struct map *map __maybe_unused, 2843static int filter_available_functions(struct map *map __maybe_unused,
2847 struct symbol *sym) 2844 struct symbol *sym)
2848{ 2845{
2849 if ((sym->binding == STB_GLOBAL || sym->binding == STB_LOCAL) && 2846 if (strfilter__compare(available_func_filter, sym->name))
2850 strfilter__compare(available_func_filter, sym->name))
2851 return 0; 2847 return 0;
2852 return 1; 2848 return 1;
2853} 2849}