]> git.tdb.fi Git - libs/core.git/blob - source/debug/demangle.cpp
5c348514fd9bffa57ec0d7cbf6acb4539d198880
[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 <cstdlib>
9 #include <cxxabi.h>
10 #include "demangle.h"
11
12 using namespace std;
13
14 namespace Msp {
15 namespace Debug {
16
17 string demangle(const string &sym)
18 {
19 #ifdef __GNUC__
20         int status;
21         char *dm=abi::__cxa_demangle(sym.c_str(), 0, 0, &status);
22         
23         string result;
24         if(status==0)
25                 result=dm;
26         else
27                 result=sym;
28         
29         free(dm);
30
31         return result;
32 #else
33         return sym;
34 #endif
35 }
36
37 } // namespace Debug
38 } // namespace Msp