From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753890AbbCDFsH (ORCPT ); Wed, 4 Mar 2015 00:48:07 -0500 Received: from mail4.hitachi.co.jp ([133.145.228.5]:45413 "EHLO mail4.hitachi.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751125AbbCDFsG (ORCPT ); Wed, 4 Mar 2015 00:48:06 -0500 Message-ID: <54F69C8D.9030207@hitachi.com> Date: Wed, 04 Mar 2015 14:47:57 +0900 From: Masami Hiramatsu Organization: Hitachi, Ltd., Japan User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: Namhyung Kim CC: Arnaldo Carvalho de Melo , Naohiro Aota , Peter Zijlstra , Linux Kernel Mailing List , David Ahern , Jiri Olsa , Ingo Molnar Subject: Re: Re: [PATCH perf/core 2/4] perf-probe: Fix to handle aliased symbols in glibc References: <20150302124939.9191.33564.stgit@localhost.localdomain> <20150302124953.9191.16348.stgit@localhost.localdomain> <20150303133124.GA27046@danjae> In-Reply-To: <20150303133124.GA27046@danjae> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (2015/03/03 22:31), Namhyung Kim wrote: > 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. Right, I also hit same problem on waitpid, which is also an weak symbol. > 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. I'm just using struct map and dso, so those should be improved. Thank you, -- Masami HIRAMATSU Software Platform Research Dept. Linux Technology Research Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: masami.hiramatsu.pt@hitachi.com