summaryrefslogtreecommitdiff
path: root/tools/perf/util/symbol-elf.c
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2013-09-12 08:16:38 -0700
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-09-25 12:58:21 -0300
commitde95ab53645a2f0015e0f68ee723f18dce2b8b51 (patch)
tree21891fca93bb0bd907311beafdae15f6cd59f58d /tools/perf/util/symbol-elf.c
parentaa7fe3b0c499fb7987245ac40295af03546f2bd2 (diff)
perf symbols: Demangle cloned functions
The libbfd C++ demangler doesn't seem to deal with cloned functions, like symbol.clone.NUM. Just strip the dot part before demangling and add it back later. Signed-off-by: Andi Kleen <ak@linux.intel.com> Link: http://lkml.kernel.org/r/1378998998-10802-1-git-send-email-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/symbol-elf.c')
-rw-r--r--tools/perf/util/symbol-elf.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index a9c829be5216..d2a888e2e058 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -928,8 +928,33 @@ int dso__load_sym(struct dso *dso, struct map *map,
* to it...
*/
if (symbol_conf.demangle) {
- demangled = bfd_demangle(NULL, elf_name,
+ /*
+ * The demangler doesn't deal with cloned functions.
+ * XXXX.clone.NUM or similar
+ * Strip the dot part and readd it later.
+ */
+ char *p = (char *)elf_name, *dot;
+ dot = strchr(elf_name, '.');
+ if (dot) {
+ p = strdup(elf_name);
+ if (!p)
+ goto new_symbol;
+ dot = strchr(p, '.');
+ *dot = 0;
+ }
+
+ demangled = bfd_demangle(NULL, p,
DMGL_PARAMS | DMGL_ANSI);
+ if (dot)
+ *dot = '.';
+ if (demangled && dot) {
+ demangled = realloc(demangled, strlen(demangled) + strlen(dot) + 1);
+ if (!demangled)
+ goto new_symbol;
+ strcpy(demangled + (dot - p), dot);
+ }
+ if (p != elf_name)
+ free(p);
if (demangled != NULL)
elf_name = demangled;
}