From: Namhyung Kim <namhyung@kernel.org>
To: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Naohiro Aota <naota@elisp.net>,
Peter Zijlstra <peterz@infradead.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
David Ahern <dsahern@gmail.com>, Jiri Olsa <jolsa@redhat.com>,
Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH perf/core 2/4] perf-probe: Fix to handle aliased symbols in glibc
Date: Tue, 3 Mar 2015 22:31:24 +0900 [thread overview]
Message-ID: <20150303133124.GA27046@danjae> (raw)
In-Reply-To: <20150302124953.9191.16348.stgit@localhost.localdomain>
Hi Masami,
On Mon, Mar 02, 2015 at 09:49:53PM +0900, Masami Hiramatsu wrote:
> Fix perf probe to handle aliased symbols correctly in glibc.
> In the glibc, several symbols are defined as an alias of
> __libc_XXX, e.g. malloc is an alias of __libc_malloc.
> In such cases, dwarf has no subroutine instances of the
> alias functions (e.g. no "malloc" instance), but the map
> has that symbol and its address.
> Thus, if we search the alieased symbol in debuginfo, we
> always fail to find it, but it is in the map.
>
> To solve this problem, this fails back to address-based
> alternative search, which searches the symbol in the map,
> translates its address to alternative (correct) function
> name by using debuginfo, and retry to find the alternative
> function point from debuginfo.
>
> This adds fail-back process to --vars, --lines and --add
> options. So, now you can use those on malloc@libc :)
So this is only for binaries that have debuginfo, right?
I have a similar issue with no debuginfo.
$ perf probe -x /usr/lib/libc.so.6 -V calloc
The /usr/lib/libc-2.21.so file has no debug information.
Rebuild with -g, or install an appropriate debuginfo package.
Error: Failed to show vars.
But it also failed to add a probe to calloc:
$ 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.
Of course there's calloc in the libc binary.
$ nm /usr/lib/libc.so.6 | grep calloc
000000000007b1f0 t __calloc
000000000007b1f0 T __libc_calloc
000000000007b1f0 W calloc
I think the problem is that calloc is a weak symbol so it'll be
discarded during the symbol loading. It's because to avoid multiple
symbols (or aliases) at a same address so we choose a better symbol
using heuristics. But for this case I think we can allow aliases
since it's used only for finding probe points.
Thanks,
Namhyung
next prev parent reply other threads:[~2015-03-03 13:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-02 12:49 [PATCH perf/core 0/4] perf-probe: improve glibc support Masami Hiramatsu
2015-03-02 12:49 ` [PATCH perf/core 1/4] [RESEND][BUGFIX] perf-probe: Remove bias offset to find probe point by address Masami Hiramatsu
2015-03-03 6:26 ` [tip:perf/core] perf probe: " tip-bot for Masami Hiramatsu
2015-03-02 12:49 ` [PATCH perf/core 2/4] perf-probe: Fix to handle aliased symbols in glibc Masami Hiramatsu
2015-03-02 15:46 ` Arnaldo Carvalho de Melo
2015-03-03 2:39 ` Masami Hiramatsu
2015-03-03 2:45 ` Arnaldo Carvalho de Melo
2015-03-03 3:05 ` Arnaldo Carvalho de Melo
2015-03-03 4:11 ` Masami Hiramatsu
2015-03-03 4:24 ` Arnaldo Carvalho de Melo
2015-03-03 13:31 ` Namhyung Kim [this message]
2015-03-04 5:47 ` Masami Hiramatsu
2015-03-02 12:50 ` [PATCH perf/core 3/4] perf-probe: Fix --line " Masami Hiramatsu
2015-03-02 12:50 ` [PATCH perf/core 4/4] Revert "perf probe: Fix to fall back to find probe point in symbols" Masami Hiramatsu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150303133124.GA27046@danjae \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=dsahern@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@kernel.org \
--cc=naota@elisp.net \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).