From f2fc1a128fd75a3894030df7ba15f1e8545893dc Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 20 Jul 2009 14:14:12 -0300 Subject: [PATCH] --- yaml --- r: 155726 b: refs/heads/master c: 28ac909b49a155856c957d080f8a796b3c1d1f3e h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/tools/perf/Makefile | 2 +- trunk/tools/perf/util/symbol.c | 21 +++++++++++++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/[refs] b/[refs] index c381baafc314..d521c272394c 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: dfe5a50461db90fab901cb697eff0d3d2e9fd229 +refs/heads/master: 28ac909b49a155856c957d080f8a796b3c1d1f3e diff --git a/trunk/tools/perf/Makefile b/trunk/tools/perf/Makefile index 7822b3d6baca..a5e9b876ca09 100644 --- a/trunk/tools/perf/Makefile +++ b/trunk/tools/perf/Makefile @@ -345,7 +345,7 @@ BUILTIN_OBJS += builtin-stat.o BUILTIN_OBJS += builtin-top.o PERFLIBS = $(LIB_FILE) -EXTLIBS = +EXTLIBS = -lbfd # # Platform specific tweaks diff --git a/trunk/tools/perf/util/symbol.c b/trunk/tools/perf/util/symbol.c index f40266b4845d..98aee922acca 100644 --- a/trunk/tools/perf/util/symbol.c +++ b/trunk/tools/perf/util/symbol.c @@ -6,9 +6,15 @@ #include #include #include +#include const char *sym_hist_filter; +#ifndef DMGL_PARAMS +#define DMGL_PARAMS (1 << 0) /* Include function args */ +#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */ +#endif + static struct symbol *symbol__new(u64 start, u64 len, const char *name, unsigned int priv_size, u64 obj_start, int verbose) @@ -571,6 +577,8 @@ static int dso__load_sym(struct dso *self, int fd, const char *name, NULL) != NULL); elf_symtab__for_each_symbol(syms, nr_syms, index, sym) { struct symbol *f; + const char *name; + char *demangled; u64 obj_start; struct section *section = NULL; int is_label = elf_sym__is_label(&sym); @@ -609,10 +617,19 @@ static int dso__load_sym(struct dso *self, int fd, const char *name, goto out_elf_end; } } + /* + * We need to figure out if the object was created from C++ sources + * DWARF DW_compile_unit has this, but we don't always have access + * to it... + */ + name = elf_sym__name(&sym, symstrs); + demangled = bfd_demangle(NULL, name, DMGL_PARAMS | DMGL_ANSI); + if (demangled != NULL) + name = demangled; - f = symbol__new(sym.st_value, sym.st_size, - elf_sym__name(&sym, symstrs), + f = symbol__new(sym.st_value, sym.st_size, name, self->sym_priv_size, obj_start, verbose); + free(demangled); if (!f) goto out_elf_end;