From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756459AbbCCNcI (ORCPT ); Tue, 3 Mar 2015 08:32:08 -0500 Received: from mail-pd0-f182.google.com ([209.85.192.182]:45400 "EHLO mail-pd0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756320AbbCCNcF (ORCPT ); Tue, 3 Mar 2015 08:32:05 -0500 Date: Tue, 3 Mar 2015 22:31:24 +0900 From: Namhyung Kim To: Masami Hiramatsu Cc: Arnaldo Carvalho de Melo , Naohiro Aota , Peter Zijlstra , Linux Kernel Mailing List , David Ahern , Jiri Olsa , Ingo Molnar Subject: Re: [PATCH perf/core 2/4] perf-probe: Fix to handle aliased symbols in glibc Message-ID: <20150303133124.GA27046@danjae> References: <20150302124939.9191.33564.stgit@localhost.localdomain> <20150302124953.9191.16348.stgit@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20150302124953.9191.16348.stgit@localhost.localdomain> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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