summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@theqtcompany.com>2015-02-27 16:27:18 +0100
committerUlf Hermann <ulf.hermann@theqtcompany.com>2015-03-04 11:18:37 +0200
commit5bae739b6b490b201ef41fbc7942702df2eac24a (patch)
treeb5341853fc6ff65eb99af221ad07caad9fecdbd9
parentcf23d7740f54b8c53409e70eea244d984a27e537 (diff)
Get rid of libbfd dependency by using gcc's __cxa_demangle instead
If we want to build it on a different platform we'll have to come up with some #ifdefs, but for now that should be fine. Change-Id: Ied7c5fa84dd3518576e405e0dc844149022a0a90 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
-rw-r--r--app/app.pro2
-rw-r--r--app/perfunwind.cpp14
2 files changed, 10 insertions, 6 deletions
diff --git a/app/app.pro b/app/app.pro
index 36bf0fe..aa2e460 100644
--- a/app/app.pro
+++ b/app/app.pro
@@ -18,7 +18,7 @@ LIBS += -Wl,--start-group \
../3rdparty/elfutils/libebl.a \
../3rdparty/elfutils/libdwelf.a \
-Wl,--end-group \
- -Wl,-Bstatic -lbfd -Wl,-Bdynamic -lz -ldl -liberty
+ -lz -ldl -liberty
TARGET = ../perfparser
CONFIG += console c++11
diff --git a/app/perfunwind.cpp b/app/perfunwind.cpp
index b79a868..1bbb118 100644
--- a/app/perfunwind.cpp
+++ b/app/perfunwind.cpp
@@ -21,12 +21,11 @@
#include "perfunwind.h"
#include "perfregisterinfo.h"
-#include <bfd.h>
-
#include <QDir>
#include <QDebug>
#include <limits>
+#include <cxxabi.h>
PerfUnwind::PerfUnwind(QIODevice *output, const QString &systemRoot, const QString &debugPath,
const QString &extraLibsPath, const QString &appPath) :
@@ -211,7 +210,6 @@ static PerfUnwind::Frame lookupSymbol(PerfUnwind::UnwindInfo *ui, Dwfl *dwfl, Dw
{
Dwfl_Module *mod = dwfl_addrmodule (dwfl, ip);
const char *symname = NULL;
- const char *demangled = NULL;
if (!mod)
mod = ui->unwind->reportElf(ip, isKernel ? PerfUnwind::s_kernelPid : ui->unwind->pid());
@@ -228,11 +226,17 @@ static PerfUnwind::Frame lookupSymbol(PerfUnwind::UnwindInfo *ui, Dwfl *dwfl, Dw
}
if (symname) {
- demangled = bfd_demangle(NULL, symname, 0x3);
+ char *demangled = NULL;
+ int status = -1;
+ if (symname[0] == '_' && symname[1] == 'Z') {
+ demangled = abi::__cxa_demangle (symname, 0, 0, &status);
+ }
+
// Adjust it back. The symtab entries are 1 off for all practical purposes.
return PerfUnwind::Frame((do_adjust && (sym.st_value & 1)) ? sym.st_value - 1 :
sym.st_value,
- isKernel, demangled ? demangled : symname, filename);
+ isKernel, status == 0 ? demangled : symname, filename);
+ free(demangled);
} else {
qWarning() << "no symbol found for" << ip << "in" << filename;
ui->broken = !isKernel;