Skip to content

Commit 87a3fc7

Browse files
committed
new : demangle c++ names (clang)
1 parent c519e08 commit 87a3fc7

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ qrc_*.cpp
66
/Makefile
77
/Qldd
88
*.qmake.stash
9+
/cmake-build-Debug/
10+
/cmake-build-Release/

Qldd.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ TARGET = Qldd
1212
TEMPLATE = app
1313

1414
macx {
15-
QMAKE_MAC_SDK = macosx10.11
15+
QMAKE_MAC_SDK = macosx10.15
1616
}
1717

1818
SOURCES += main.cpp\

qldd.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
#include <sys/types.h>
88
#include <pwd.h>
99
#include <grp.h>
10+
#include <cstdlib>
1011
#include <QTreeWidgetItem>
1112
#include <QListWidgetItem>
1213

14+
#include <cxxabi.h>
15+
1316
#define MAXBUFFER 512
1417

1518
using namespace std;
@@ -190,8 +193,15 @@ void QLdd::fillExportTable(QListWidget &listWidget) {
190193
while (fgets(buffer, MAXBUFFER, stream) != NULL) {
191194
buf.clear();
192195
buf = QString::fromLocal8Bit(buffer).trimmed();
193-
194-
listWidget.addItem(new QListWidgetItem(buf));
196+
QStringList info = buf.split(" ");
197+
QString demangled(info.at(2));
198+
int status = 0;
199+
char *realname = abi::__cxa_demangle(info.at(2).toStdString().c_str(), nullptr, nullptr, &status);
200+
demangled = QString::fromLocal8Bit(realname);
201+
::free(realname);
202+
demangled.replace(":__1:", "");
203+
demangled.replace("std::basic_string<char, std::char_traits<char>, std::allocator<char> >", "std::string");
204+
listWidget.addItem(new QListWidgetItem(info.at(0) + " " + demangled));
195205

196206
memset(&buffer, 0, sizeof(buffer));
197207
}

0 commit comments

Comments
 (0)