All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Jiri Olsa <jolsa@redhat.com>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [RFC/PATCH 2/2] perf probe: Allow weak symbols to be probed
Date: Fri, 06 Mar 2015 16:05:49 +0900	[thread overview]
Message-ID: <54F951CD.6060101@hitachi.com> (raw)
In-Reply-To: <1425477143-5310-2-git-send-email-namhyung@kernel.org>

(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.
> 
> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  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++;
>  	}

Ah, I've found this is the magic...
Here, we need another fix on my series.

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 22392b06..f9c1e53 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -309,10 +309,8 @@ static int find_alternative_probe_point(struct debuginfo *d

        /* Find the address of given function */
        map__for_each_symbol_by_name(map, pp->function, sym) {
-               if (sym->binding == STB_GLOBAL || sym->binding == STB_LOCAL) {
-                       address = sym->start;
-                       break;
-               }
+               address = sym->start;
+               break;
        }
        if (!address) {
                ret = -ENOENT;
-------

With this fix, I could get variables on waitpid and calloc.
-----
# ./perf probe -x /lib64/libc-2.17.so -V waitpid
Available variables at waitpid
        @<__libc_waitpid+0>
                __pid_t pid
                int     oldtype
                int     options
                int*    stat_loc
-----

I'll update and include it my series.

Thank you!

>  
>  	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@hitachi.com



  parent reply	other threads:[~2015-03-06  7:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-04 13:52 [RFC/PATCH 1/2] perf symbols: Allow symbol alias when loading map for symbol name Namhyung Kim
2015-03-04 13:52 ` [RFC/PATCH 2/2] perf probe: Allow weak symbols to be probed Namhyung Kim
2015-03-04 15:57   ` Masami Hiramatsu
2015-03-06  6:15     ` Namhyung Kim
2015-03-06  6:36       ` Masami Hiramatsu
2015-03-06  7:05   ` Masami Hiramatsu [this message]
2015-03-06  7:28     ` Namhyung Kim

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=54F951CD.6060101@hitachi.com \
    --to=masami.hiramatsu.pt@hitachi.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.