mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-16 03:31:02 +01:00
Add support for demangling symbols on Linux.
This commit is contained in:
parent
822d766a04
commit
5280ddf3d7
@ -183,9 +183,7 @@ QDebug CreateLogger(Level level, const QString& class_name, int line) {
|
||||
return ret.space();
|
||||
}
|
||||
|
||||
QString DemangleSymbol(const QString& symbol) {
|
||||
QStringList split = symbol.split(' ', QString::SkipEmptyParts);
|
||||
QString mangled_function = split[3];
|
||||
QString CXXDemangle(const QString& mangled_function) {
|
||||
int status;
|
||||
char* demangled_function = abi::__cxa_demangle(
|
||||
mangled_function.toAscii().constData(),
|
||||
@ -200,6 +198,31 @@ QString DemangleSymbol(const QString& symbol) {
|
||||
return mangled_function; // Probably not a C++ function.
|
||||
}
|
||||
|
||||
QString DarwinDemangle(const QString& symbol) {
|
||||
QStringList split = symbol.split(' ', QString::SkipEmptyParts);
|
||||
QString mangled_function = split[3];
|
||||
return CXXDemangle(mangled_function);
|
||||
}
|
||||
|
||||
QString LinuxDemangle(const QString& symbol) {
|
||||
QRegExp regex("\\(([^+]+)");
|
||||
if (!symbol.contains(regex)) {
|
||||
return symbol;
|
||||
}
|
||||
QString mangled_function = regex.cap(1);
|
||||
return CXXDemangle(mangled_function);
|
||||
}
|
||||
|
||||
QString DemangleSymbol(const QString& symbol) {
|
||||
#ifdef Q_OS_DARWIN
|
||||
return DarwinDemangle(symbol);
|
||||
#elif defined(Q_OS_LINUX)
|
||||
return LinuxDemangle(symbol);
|
||||
#else
|
||||
return symbol;
|
||||
#endif
|
||||
}
|
||||
|
||||
void DumpStackTrace() {
|
||||
#ifdef Q_OS_UNIX
|
||||
void* callstack[128];
|
||||
|
Loading…
Reference in New Issue
Block a user