aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-07-20 13:14:12 -0400
committerPeter Zijlstra <a.p.zijlstra@chello.nl>2009-07-22 12:05:57 -0400
commit28ac909b49a155856c957d080f8a796b3c1d1f3e (patch)
treecdc46c36edc29c1847cabd98b7f5e35e2c39e778 /tools/perf/util
parentdfe5a50461db90fab901cb697eff0d3d2e9fd229 (diff)
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: Clark Williams <williams@redhat.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <20090720171412.GB10410@ghostprotocols.net>
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/symbol.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index f40266b4845d..98aee922acca 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -6,9 +6,15 @@
6#include <libelf.h> 6#include <libelf.h>
7#include <gelf.h> 7#include <gelf.h>
8#include <elf.h> 8#include <elf.h>
9#include <bfd.h>
9 10
10const char *sym_hist_filter; 11const char *sym_hist_filter;
11 12
13#ifndef DMGL_PARAMS
14#define DMGL_PARAMS (1 << 0) /* Include function args */
15#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */
16#endif
17
12static struct symbol *symbol__new(u64 start, u64 len, 18static struct symbol *symbol__new(u64 start, u64 len,
13 const char *name, unsigned int priv_size, 19 const char *name, unsigned int priv_size,
14 u64 obj_start, int verbose) 20 u64 obj_start, int verbose)
@@ -571,6 +577,8 @@ static int dso__load_sym(struct dso *self, int fd, const char *name,
571 NULL) != NULL); 577 NULL) != NULL);
572 elf_symtab__for_each_symbol(syms, nr_syms, index, sym) { 578 elf_symtab__for_each_symbol(syms, nr_syms, index, sym) {
573 struct symbol *f; 579 struct symbol *f;
580 const char *name;
581 char *demangled;
574 u64 obj_start; 582 u64 obj_start;
575 struct section *section = NULL; 583 struct section *section = NULL;
576 int is_label = elf_sym__is_label(&sym); 584 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 goto out_elf_end; 617 goto out_elf_end;
610 } 618 }
611 } 619 }
620 /*
621 * We need to figure out if the object was created from C++ sources
622 * DWARF DW_compile_unit has this, but we don't always have access
623 * to it...
624 */
625 name = elf_sym__name(&sym, symstrs);
626 demangled = bfd_demangle(NULL, name, DMGL_PARAMS | DMGL_ANSI);
627 if (demangled != NULL)
628 name = demangled;
612 629
613 f = symbol__new(sym.st_value, sym.st_size, 630 f = symbol__new(sym.st_value, sym.st_size, name,
614 elf_sym__name(&sym, symstrs),
615 self->sym_priv_size, obj_start, verbose); 631 self->sym_priv_size, obj_start, verbose);
632 free(demangled);
616 if (!f) 633 if (!f)
617 goto out_elf_end; 634 goto out_elf_end;
618 635