Re: [RFC/PATCH 2/2] perf probe: Allow weak symbols to be probed
From: Masami Hiramatsu
Date: Wed Mar 04 2015 - 10:57:33 EST
(2015/03/04 22:52), Namhyung Kim wrote:
> 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.
Hmm, even on my previous series, I got an error with calloc and waitpid.
$ ./perf probe -x /usr/lib64/libc-2.17.so -vvV calloc
probe-definition(0): calloc
symbol:calloc file:(null) line:0 offset:0 return:0 lazy:(null)
0 arguments
Open Debuginfo file: /usr/lib/debug/usr/lib64/libc-2.17.so.debug
Searching variables at calloc
Failed to find the address of calloc
Error: Failed to show vars. Reason: No such file or directory (Code: -2)
However, it seems that calloc is loaded as a symbol.
$ ./perf probe -x /usr/lib64/libc-2.17.so -vvvvV calloc
...
symbol__new: __xstat64 0xe7340-0xe7385
symbol__new: calloc 0x80a90-0x80d2a
symbol__new: msgget 0xf7940-0xf7961
...
FYI, without these patches, I see the same result (calloc is loaded)
Thank you,
>
> Cc: Masami Hiramatsu <masami.hiramatsu.pt@xxxxxxxxxxx>
> Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
> ---
> tools/perf/util/probe-event.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index 1c570c2fa7cc..12b7d018106e 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -2339,8 +2339,7 @@ static int find_probe_functions(struct map *map, char *name)
> struct symbol *sym;
>
> map__for_each_symbol_by_name(map, name, sym) {
> - if (sym->binding == STB_GLOBAL || sym->binding == STB_LOCAL)
> - found++;
> + found++;
> }
>
> return found;
> @@ -2708,8 +2707,7 @@ static struct strfilter *available_func_filter;
> static int filter_available_functions(struct map *map __maybe_unused,
> struct symbol *sym)
> {
> - if ((sym->binding == STB_GLOBAL || sym->binding == STB_LOCAL) &&
> - strfilter__compare(available_func_filter, sym->name))
> + if (strfilter__compare(available_func_filter, sym->name))
> return 0;
> return 1;
> }
>
--
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@xxxxxxxxxxx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/