Commit 031b84c4 authored by Naveen N. Rao's avatar Naveen N. Rao Committed by Arnaldo Carvalho de Melo

perf probe ppc: Enable matching against dot symbols automatically

Allow perf probe to work on ppc ABIv1 without the need to specify the
leading dot '.' for functions. 'perf probe do_fork' works with this
patch.

We do this by changing how symbol name comparison works on ppc ABIv1 -
we simply ignore and skip over the initial dot, if one exists, during
symbol name comparison.
Signed-off-by: default avatarNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Reviewed-by: default avatarSrikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Cc: linuxppc-dev@lists.ozlabs.org
Link: http://lkml.kernel.org/r/652a8f3bfa919bd02a1836a128370eaed59b4a34.1430217967.git.naveen.n.rao@linux.vnet.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent fb6d5942
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "debug.h" #include "debug.h"
#include "symbol.h" #include "symbol.h"
#include "map.h"
#ifdef HAVE_LIBELF_SUPPORT #ifdef HAVE_LIBELF_SUPPORT
bool elf__needs_adjust_symbols(GElf_Ehdr ehdr) bool elf__needs_adjust_symbols(GElf_Ehdr ehdr)
...@@ -36,4 +37,16 @@ int arch__choose_best_symbol(struct symbol *syma, ...@@ -36,4 +37,16 @@ int arch__choose_best_symbol(struct symbol *syma,
return SYMBOL_A; return SYMBOL_A;
} }
/* Allow matching against dot variants */
int arch__compare_symbol_names(const char *namea, const char *nameb)
{
/* Skip over initial dot */
if (*namea == '.')
namea++;
if (*nameb == '.')
nameb++;
return strcmp(namea, nameb);
}
#endif #endif
...@@ -292,6 +292,11 @@ int map__load(struct map *map, symbol_filter_t filter) ...@@ -292,6 +292,11 @@ int map__load(struct map *map, symbol_filter_t filter)
return 0; return 0;
} }
int __weak arch__compare_symbol_names(const char *namea, const char *nameb)
{
return strcmp(namea, nameb);
}
struct symbol *map__find_symbol(struct map *map, u64 addr, struct symbol *map__find_symbol(struct map *map, u64 addr,
symbol_filter_t filter) symbol_filter_t filter)
{ {
......
...@@ -124,7 +124,7 @@ struct thread; ...@@ -124,7 +124,7 @@ struct thread;
*/ */
#define __map__for_each_symbol_by_name(map, sym_name, pos, filter) \ #define __map__for_each_symbol_by_name(map, sym_name, pos, filter) \
for (pos = map__find_symbol_by_name(map, sym_name, filter); \ for (pos = map__find_symbol_by_name(map, sym_name, filter); \
pos && strcmp(pos->name, sym_name) == 0; \ pos && arch__compare_symbol_names(pos->name, sym_name) == 0; \
pos = symbol__next_by_name(pos)) pos = symbol__next_by_name(pos))
#define map__for_each_symbol_by_name(map, sym_name, pos) \ #define map__for_each_symbol_by_name(map, sym_name, pos) \
...@@ -132,6 +132,7 @@ struct thread; ...@@ -132,6 +132,7 @@ struct thread;
typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym); typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym);
int arch__compare_symbol_names(const char *namea, const char *nameb);
void map__init(struct map *map, enum map_type type, void map__init(struct map *map, enum map_type type,
u64 start, u64 end, u64 pgoff, struct dso *dso); u64 start, u64 end, u64 pgoff, struct dso *dso);
struct map *map__new(struct machine *machine, u64 start, u64 len, struct map *map__new(struct machine *machine, u64 start, u64 len,
......
...@@ -411,7 +411,7 @@ static struct symbol *symbols__find_by_name(struct rb_root *symbols, ...@@ -411,7 +411,7 @@ static struct symbol *symbols__find_by_name(struct rb_root *symbols,
int cmp; int cmp;
s = rb_entry(n, struct symbol_name_rb_node, rb_node); s = rb_entry(n, struct symbol_name_rb_node, rb_node);
cmp = strcmp(name, s->sym.name); cmp = arch__compare_symbol_names(name, s->sym.name);
if (cmp < 0) if (cmp < 0)
n = n->rb_left; n = n->rb_left;
...@@ -429,7 +429,7 @@ static struct symbol *symbols__find_by_name(struct rb_root *symbols, ...@@ -429,7 +429,7 @@ static struct symbol *symbols__find_by_name(struct rb_root *symbols,
struct symbol_name_rb_node *tmp; struct symbol_name_rb_node *tmp;
tmp = rb_entry(n, struct symbol_name_rb_node, rb_node); tmp = rb_entry(n, struct symbol_name_rb_node, rb_node);
if (strcmp(tmp->sym.name, s->sym.name)) if (arch__compare_symbol_names(tmp->sym.name, s->sym.name))
break; break;
s = tmp; s = tmp;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment