X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fdebug%2Fdemangle.cpp;fp=source%2Fdebug%2Fdemangle.cpp;h=58e05cefd58e687fb22928ea02c6fc602a1bca2e;hp=0000000000000000000000000000000000000000;hb=521cf1db00f8ce2d9f9494dca503d6c17d89ac2f;hpb=80bbee2f401b4af71cb1b80508bdb0d2bb61fa40 diff --git a/source/debug/demangle.cpp b/source/debug/demangle.cpp new file mode 100644 index 0000000..58e05ce --- /dev/null +++ b/source/debug/demangle.cpp @@ -0,0 +1,50 @@ +/* $Id$ + +This file is part of libmspcore +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ +#include "demangle.h" + +using namespace std; + +namespace Msp { +namespace Debug { + +string demangle_gcc3(const string &sym) +{ + 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; + } +} + +} // namespace Debug +} // namespace Msp