X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fdebug%2Fdemangle.cpp;h=e41eb9ad79f32152b92503d33168c6dd1a43d337;hp=bb59bd72f1d1acabd2b9e69c45050dcd9a3f0d72;hb=292aed8e23ea543b089d5f2a73000de4640befe7;hpb=9e8e96c9e98e4aed3713ca09011aebafc9f62f87 diff --git a/source/debug/demangle.cpp b/source/debug/demangle.cpp index bb59bd7..e41eb9a 100644 --- a/source/debug/demangle.cpp +++ b/source/debug/demangle.cpp @@ -1,9 +1,7 @@ -/* $Id$ - -This file is part of libmspcore -Copyright © 2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ +#include +#ifdef __GNUC__ +#include +#endif #include "demangle.h" using namespace std; @@ -11,41 +9,24 @@ using namespace std; namespace Msp { namespace Debug { -string demangle_gcc3(const string &sym) +string demangle(const string &sym) { +#ifdef __GNUC__ + int status; + char *dm = abi::__cxa_demangle(sym.c_str(), 0, 0, &status); + string result; - - if(sym.compare(0, 2, "_Z")) - return result; - - string::const_iterator i=sym.begin()+2; - - bool nested=(*i=='N'); - bool first=true; - while(first || (nested && *i!='E')) - { - unsigned len=0; - for(; isdigit(*i); ++i) - len=len*10+(*i-'0'); - string::const_iterator j=i+len; - - if(!first) - result.append("::"); - result.append(i, j); - - first=false; - } - - if(nested) - ++i; - - for(; i!=sym.end(); ++i) - { - bool ref=(*i=='R'); - if(ref) ++i; - } + if(status==0) + result = dm; + else + result = sym; + + free(dm); return result; +#else + return sym; +#endif } } // namespace Debug