Commit 28ac909b authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo Committed by Peter Zijlstra

perf symbol: C++ demangling

[acme@doppio ~]$ perf report -s comm,dso,symbol -C firefox -d /usr/lib64/xulrunner-1.9.1/libxul.so | grep :: | head
     2.21%  [.] nsDeque::Push(void*)
     1.78%  [.] GraphWalker::DoWalk(nsDeque&)
     1.30%  [.] GCGraphBuilder::AddNode(void*, nsCycleCollectionParticipant*)
     1.27%  [.] XPCWrappedNative::CallMethod(XPCCallContext&, XPCWrappedNative::CallMode)
     1.18%  [.] imgContainer::DrawFrameTo(gfxIImageFrame*, gfxIImageFrame*, nsRect&)
     1.13%  [.] nsDeque::PopFront()
     1.11%  [.] nsGlobalWindow::RunTimeout(nsTimeout*)
     0.97%  [.] nsXPConnect::Traverse(void*, nsCycleCollectionTraversalCallback&)
     0.95%  [.] nsJSEventListener::cycleCollection::Traverse(void*, nsCycleCollectionTraversalCallback&)
     0.95%  [.] nsCOMPtr_base::~nsCOMPtr_base()
[acme@doppio ~]$

Cc: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Vegard Nossum <vegard.nossum@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Suggested-by: default avatarClark Williams <williams@redhat.com>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <20090720171412.GB10410@ghostprotocols.net>
parent dfe5a504
...@@ -345,7 +345,7 @@ BUILTIN_OBJS += builtin-stat.o ...@@ -345,7 +345,7 @@ BUILTIN_OBJS += builtin-stat.o
BUILTIN_OBJS += builtin-top.o BUILTIN_OBJS += builtin-top.o
PERFLIBS = $(LIB_FILE) PERFLIBS = $(LIB_FILE)
EXTLIBS = EXTLIBS = -lbfd
# #
# Platform specific tweaks # Platform specific tweaks
......
...@@ -6,9 +6,15 @@ ...@@ -6,9 +6,15 @@
#include <libelf.h> #include <libelf.h>
#include <gelf.h> #include <gelf.h>
#include <elf.h> #include <elf.h>
#include <bfd.h>
const char *sym_hist_filter; 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, static struct symbol *symbol__new(u64 start, u64 len,
const char *name, unsigned int priv_size, const char *name, unsigned int priv_size,
u64 obj_start, int verbose) u64 obj_start, int verbose)
...@@ -571,6 +577,8 @@ static int dso__load_sym(struct dso *self, int fd, const char *name, ...@@ -571,6 +577,8 @@ static int dso__load_sym(struct dso *self, int fd, const char *name,
NULL) != NULL); NULL) != NULL);
elf_symtab__for_each_symbol(syms, nr_syms, index, sym) { elf_symtab__for_each_symbol(syms, nr_syms, index, sym) {
struct symbol *f; struct symbol *f;
const char *name;
char *demangled;
u64 obj_start; u64 obj_start;
struct section *section = NULL; struct section *section = NULL;
int is_label = elf_sym__is_label(&sym); 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, ...@@ -609,10 +617,19 @@ static int dso__load_sym(struct dso *self, int fd, const char *name,
goto out_elf_end; 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, f = symbol__new(sym.st_value, sym.st_size, name,
elf_sym__name(&sym, symstrs),
self->sym_priv_size, obj_start, verbose); self->sym_priv_size, obj_start, verbose);
free(demangled);
if (!f) if (!f)
goto out_elf_end; goto out_elf_end;
......
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