From: Mikko Rasa Date: Mon, 17 Sep 2007 10:51:07 +0000 (+0000) Subject: Remove the custom demangle function and use GCC's abi::__cxa_demangle instead X-Git-Tag: 1.0~20 X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=commitdiff_plain;h=0fa00d18f607f329d2b2a979e1d4339e233817fa Remove the custom demangle function and use GCC's abi::__cxa_demangle instead Demangle uncaught exception type Return a special error code on uncaught exception Use vector instead of list or GetOpt::get_args() --- diff --git a/source/core/application.cpp b/source/core/application.cpp index 0e0b69f..a498023 100644 --- a/source/core/application.cpp +++ b/source/core/application.cpp @@ -6,6 +6,7 @@ Distributed under the LGPL */ #include #include +#include "../debug/demangle.h" #include "../time/units.h" #include "../time/utils.h" #include "application.h" @@ -57,10 +58,10 @@ int Application::run(int argc, char **argv) catch(const exception &e) { cerr<<"An uncaught exception occurred.\n"; - cerr<<" type: "< #include #include +#include #include "error.h" namespace Msp { @@ -46,7 +46,7 @@ public: OptBase(char s, const std::string &l, ArgType a): shrt(s), lng(l), arg_type(a), seen_count(0) { } }; - const std::list &get_args() const { return args; } + const std::vector &get_args() const { return args; } template OptBase &add_option(char s, const std::string &l, T &d, ArgType a=NO_ARG) @@ -128,7 +128,7 @@ private: }; std::list opts; - std::list args; + std::vector args; OptBase &get_option(char); OptBase &get_option(const std::string &); diff --git a/source/debug/demangle.cpp b/source/debug/demangle.cpp index bb59bd7..460410e 100644 --- a/source/debug/demangle.cpp +++ b/source/debug/demangle.cpp @@ -4,6 +4,8 @@ This file is part of libmspcore Copyright © 2007 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ + +#include #include "demangle.h" using namespace std; @@ -11,41 +13,17 @@ using namespace std; namespace Msp { namespace Debug { -string demangle_gcc3(const string &sym) +string demangle(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; - } - +#ifdef __GNUC__ + int status; + char *dm=abi::__cxa_demangle(sym.c_str(), 0, 0, &status); + string result(dm); + free(dm); return result; +#else + return sym; +#endif } } // namespace Debug diff --git a/source/debug/demangle.h b/source/debug/demangle.h index f8cab96..cf2dca2 100644 --- a/source/debug/demangle.h +++ b/source/debug/demangle.h @@ -12,7 +12,7 @@ Distributed under the LGPL namespace Msp { namespace Debug { -std::string demangle_gcc3(const std::string &); +std::string demangle(const std::string &); } // namespace Debug } // namespace Msp