LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [RFC/PATCH 1/2] perf symbols: Allow symbol alias when loading map for symbol name
@ 2015-03-04 13:52 Namhyung Kim
  2015-03-04 13:52 ` [RFC/PATCH 2/2] perf probe: Allow weak symbols to be probed Namhyung Kim
  0 siblings, 1 reply; 7+ messages in thread
From: Namhyung Kim @ 2015-03-04 13:52 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, Masami Hiramatsu

When perf probe tries to add a probe in a binary using symbol name, it
sometimes failed since some symbols were discard during loading dso.
When it resolves an address to symbol, it'd be better to have just one
symbol at given address.  But for finding address from symbol, it'd be
better to keep all names (including aliases).

Add and propagate a new allow_alias argument to dso (and map) load
functions so that it can keep those duplicate symbol aliases.

Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/machine.c        | 2 +-
 tools/perf/util/map.c            | 6 +++---
 tools/perf/util/map.h            | 8 +++++++-
 tools/perf/util/symbol-elf.c     | 5 +++--
 tools/perf/util/symbol-minimal.c | 2 +-
 tools/perf/util/symbol.c         | 8 +++++---
 tools/perf/util/symbol.h         | 5 +++--
 7 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 24f8c978cfd4..01ba9b635e4f 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1128,7 +1128,7 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
 			 * preload dso of guest kernel and modules
 			 */
 			dso__load(kernel, machine->vmlinux_maps[MAP__FUNCTION],
-				  NULL);
+				  NULL, false);
 		}
 	}
 	return 0;
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 62ca9f2607d5..711e0728520b 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -248,7 +248,7 @@ void map__fixup_end(struct map *map)
 
 #define DSO__DELETED "(deleted)"
 
-int map__load(struct map *map, symbol_filter_t filter)
+int __map__load(struct map *map, symbol_filter_t filter, bool allow_alias)
 {
 	const char *name = map->dso->long_name;
 	int nr;
@@ -256,7 +256,7 @@ int map__load(struct map *map, symbol_filter_t filter)
 	if (dso__loaded(map->dso, map->type))
 		return 0;
 
-	nr = dso__load(map->dso, map, filter);
+	nr = dso__load(map->dso, map, filter, allow_alias);
 	if (nr < 0) {
 		if (map->dso->has_build_id) {
 			char sbuild_id[BUILD_ID_SIZE * 2 + 1];
@@ -304,7 +304,7 @@ struct symbol *map__find_symbol(struct map *map, u64 addr,
 struct symbol *map__find_symbol_by_name(struct map *map, const char *name,
 					symbol_filter_t filter)
 {
-	if (map__load(map, filter) < 0)
+	if (__map__load(map, filter, true) < 0)
 		return NULL;
 
 	if (!dso__sorted_by_name(map->dso, map->type))
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index 0e42438b1e59..ba156076c25b 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -149,7 +149,13 @@ size_t map__fprintf_dsoname(struct map *map, FILE *fp);
 int map__fprintf_srcline(struct map *map, u64 addr, const char *prefix,
 			 FILE *fp);
 
-int map__load(struct map *map, symbol_filter_t filter);
+int __map__load(struct map *map, symbol_filter_t filter, bool allow_alias);
+
+static inline int map__load(struct map *map, symbol_filter_t filter)
+{
+	return __map__load(map, filter, false);
+}
+
 struct symbol *map__find_symbol(struct map *map,
 				u64 addr, symbol_filter_t filter);
 struct symbol *map__find_symbol_by_name(struct map *map, const char *name,
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index ada16762fac2..fb630f8fc45c 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -754,7 +754,7 @@ static bool want_demangle(bool is_kernel_sym)
 
 int dso__load_sym(struct dso *dso, struct map *map,
 		  struct symsrc *syms_ss, struct symsrc *runtime_ss,
-		  symbol_filter_t filter, int kmodule)
+		  symbol_filter_t filter, int kmodule, bool allow_alias)
 {
 	struct kmap *kmap = dso->kernel ? map__kmap(map) : NULL;
 	struct map *curr_map = map;
@@ -1048,7 +1048,8 @@ new_symbol:
 	 * For misannotated, zeroed, ASM function sizes.
 	 */
 	if (nr > 0) {
-		symbols__fixup_duplicate(&dso->symbols[map->type]);
+		if (!allow_alias)
+			symbols__fixup_duplicate(&dso->symbols[map->type]);
 		symbols__fixup_end(&dso->symbols[map->type]);
 		if (kmap) {
 			/*
diff --git a/tools/perf/util/symbol-minimal.c b/tools/perf/util/symbol-minimal.c
index d7efb03b3f9a..fefeeb32697e 100644
--- a/tools/perf/util/symbol-minimal.c
+++ b/tools/perf/util/symbol-minimal.c
@@ -334,7 +334,7 @@ int dso__load_sym(struct dso *dso, struct map *map __maybe_unused,
 		  struct symsrc *ss,
 		  struct symsrc *runtime_ss __maybe_unused,
 		  symbol_filter_t filter __maybe_unused,
-		  int kmodule __maybe_unused)
+		  int kmodule __maybe_unused, bool allow_alias __maybe_unused)
 {
 	unsigned char *build_id[BUILD_ID_SIZE];
 	int ret;
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index a69066865a55..de72a163758d 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1345,7 +1345,8 @@ static bool dso__is_compatible_symtab_type(struct dso *dso, bool kmod,
 	}
 }
 
-int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
+int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter,
+	      bool allow_alias)
 {
 	char *name;
 	int ret = -1;
@@ -1458,7 +1459,8 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
 		runtime_ss = syms_ss;
 
 	if (syms_ss)
-		ret = dso__load_sym(dso, map, syms_ss, runtime_ss, filter, kmod);
+		ret = dso__load_sym(dso, map, syms_ss, runtime_ss, filter, kmod,
+				    allow_alias);
 	else
 		ret = -1;
 
@@ -1516,7 +1518,7 @@ int dso__load_vmlinux(struct dso *dso, struct map *map,
 	if (symsrc__init(&ss, dso, symfs_vmlinux, symtab_type))
 		return -1;
 
-	err = dso__load_sym(dso, map, &ss, &ss, filter, 0);
+	err = dso__load_sym(dso, map, &ss, &ss, filter, 0, false);
 	symsrc__destroy(&ss);
 
 	if (err > 0) {
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 1650dcb3a67b..82990384f546 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -218,7 +218,8 @@ int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name,
 bool symsrc__has_symtab(struct symsrc *ss);
 bool symsrc__possibly_runtime(struct symsrc *ss);
 
-int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter);
+int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter,
+	      bool allow_alias);
 int dso__load_vmlinux(struct dso *dso, struct map *map,
 		      const char *vmlinux, bool vmlinux_allocated,
 		      symbol_filter_t filter);
@@ -262,7 +263,7 @@ bool symbol__is_idle(struct symbol *sym);
 
 int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss,
 		  struct symsrc *runtime_ss, symbol_filter_t filter,
-		  int kmodule);
+		  int kmodule, bool allow_alias);
 int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss,
 				struct map *map, symbol_filter_t filter);
 
-- 
2.3.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [RFC/PATCH 2/2] perf probe: Allow weak symbols to be probed
  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 ` Namhyung Kim
  2015-03-04 15:57   ` Masami Hiramatsu
  2015-03-06  7:05   ` Masami Hiramatsu
  0 siblings, 2 replies; 7+ messages in thread
From: Namhyung Kim @ 2015-03-04 13:52 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, Masami Hiramatsu

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++;
 	}
 
 	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;
 }
-- 
2.3.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC/PATCH 2/2] perf probe: Allow weak symbols to be probed
  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  7:05   ` Masami Hiramatsu
  1 sibling, 1 reply; 7+ messages in thread
From: Masami Hiramatsu @ 2015-03-04 15:57 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML

(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@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++;
>  	}
>  
>  	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



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC/PATCH 2/2] perf probe: Allow weak symbols to be probed
  2015-03-04 15:57   ` Masami Hiramatsu
@ 2015-03-06  6:15     ` Namhyung Kim
  2015-03-06  6:36       ` Masami Hiramatsu
  0 siblings, 1 reply; 7+ messages in thread
From: Namhyung Kim @ 2015-03-06  6:15 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML

Hi Masami,

On Thu, Mar 05, 2015 at 12:57:21AM +0900, Masami Hiramatsu wrote:
> (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)

I'm bit confused with the English ;-).  So you mean that now you *can*
probe calloc and waitpid with this patch, right?

Thanks,
Namhyung

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC/PATCH 2/2] perf probe: Allow weak symbols to be probed
  2015-03-06  6:15     ` Namhyung Kim
@ 2015-03-06  6:36       ` Masami Hiramatsu
  0 siblings, 0 replies; 7+ messages in thread
From: Masami Hiramatsu @ 2015-03-06  6:36 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML

(2015/03/06 15:15), Namhyung Kim wrote:
> Hi Masami,
> 
> On Thu, Mar 05, 2015 at 12:57:21AM +0900, Masami Hiramatsu wrote:
>> (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)
> 
> I'm bit confused with the English ;-).  So you mean that now you *can*
> probe calloc and waitpid with this patch, right?

Ah, sorry for confusing you. I meant that I couldn't probe it
even with your patch. I'm not sure why, since the calloc symbol
is created as above message, but can't find in the map...

Thank you,

-- 
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC/PATCH 2/2] perf probe: Allow weak symbols to be probed
  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  7:05   ` Masami Hiramatsu
  2015-03-06  7:28     ` Namhyung Kim
  1 sibling, 1 reply; 7+ messages in thread
From: Masami Hiramatsu @ 2015-03-06  7:05 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML

(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



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC/PATCH 2/2] perf probe: Allow weak symbols to be probed
  2015-03-06  7:05   ` Masami Hiramatsu
@ 2015-03-06  7:28     ` Namhyung Kim
  0 siblings, 0 replies; 7+ messages in thread
From: Namhyung Kim @ 2015-03-06  7:28 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML

On Fri, Mar 6, 2015 at 4:05 PM, Masami Hiramatsu
<masami.hiramatsu.pt@hitachi.com> wrote:
> (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.

Oops, right.  I didn't base on your patch so missed this function.

Thanks,
Namhyung


>
> 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
>
>



-- 
Thanks,
Namhyung

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-03-06  7:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2015-03-06  7:28     ` Namhyung Kim

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).