提交 e578da3b 编写于 作者: N Namhyung Kim 提交者: Arnaldo Carvalho de Melo

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: NNamhyung Kim <namhyung@kernel.org>
Tested-by: NArnaldo 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.localdomainSigned-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 680d926a
...@@ -310,10 +310,8 @@ static int find_alternative_probe_point(struct debuginfo *dinfo, ...@@ -310,10 +310,8 @@ static int find_alternative_probe_point(struct debuginfo *dinfo,
/* Find the address of given function */ /* Find the address of given function */
map__for_each_symbol_by_name(map, pp->function, sym) { map__for_each_symbol_by_name(map, pp->function, sym) {
if (sym->binding == STB_GLOBAL || sym->binding == STB_LOCAL) { address = sym->start;
address = sym->start; break;
break;
}
} }
if (!address) { if (!address) {
ret = -ENOENT; ret = -ENOENT;
...@@ -2485,8 +2483,7 @@ static int find_probe_functions(struct map *map, char *name) ...@@ -2485,8 +2483,7 @@ static int find_probe_functions(struct map *map, char *name)
struct symbol *sym; struct symbol *sym;
map__for_each_symbol_by_name(map, name, sym) { map__for_each_symbol_by_name(map, name, sym) {
if (sym->binding == STB_GLOBAL || sym->binding == STB_LOCAL) found++;
found++;
} }
return found; return found;
...@@ -2846,8 +2843,7 @@ static struct strfilter *available_func_filter; ...@@ -2846,8 +2843,7 @@ static struct strfilter *available_func_filter;
static int filter_available_functions(struct map *map __maybe_unused, static int filter_available_functions(struct map *map __maybe_unused,
struct symbol *sym) struct symbol *sym)
{ {
if ((sym->binding == STB_GLOBAL || sym->binding == STB_LOCAL) && if (strfilter__compare(available_func_filter, sym->name))
strfilter__compare(available_func_filter, sym->name))
return 0; return 0;
return 1; return 1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册