]> git.tdb.fi Git - libs/core.git/blob - source/debug/demangle.cpp
Use dladdr instead of backtrace_symbols in Backtrace::create (both are GNU-specific...
[libs/core.git] / source / debug / demangle.cpp
1 /* $Id$
2
3 This file is part of libmspcore
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #include <cxxabi.h>
9 #include "demangle.h"
10
11 using namespace std;
12
13 namespace Msp {
14 namespace Debug {
15
16 string demangle(const string &sym)
17 {
18 #ifdef __GNUC__
19         int status;
20         char *dm=abi::__cxa_demangle(sym.c_str(), 0, 0, &status);
21         
22         string result;
23         if(status==0)
24                 result=dm;
25         else
26                 result=sym;
27         
28         free(dm);
29
30         return result;
31 #else
32         return sym;
33 #endif
34 }
35
36 } // namespace Debug
37 } // namespace Msp