diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2015-06-26 15:27:06 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2015-06-26 15:27:06 -0400 |
commit | 33c88a1c6037290924691db59c6538a370946ea4 (patch) | |
tree | cba485ca46d98577b54795cce01a544c5b9628c0 | |
parent | fde0868231a25b8c9ce03a86cb53f1738d35688d (diff) |
MAINT-5232: Publish class name demangler as LLError::Log::demangle().
We've had this functionality buried in llerror.cpp for years. Make it
available for callers outside llerror.cpp too.
-rwxr-xr-x | indra/llcommon/llerror.cpp | 21 | ||||
-rwxr-xr-x | indra/llcommon/llerror.h | 1 |
2 files changed, 17 insertions, 5 deletions
diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 2100989316..f2c647c2d9 100755 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -238,6 +238,14 @@ namespace { std::string className(const std::type_info& type) { + return LLError::Log::demangle(type.name()); + } +} // anonymous + +namespace LLError +{ + std::string Log::demangle(const char* mangled) + { #ifdef __GNUC__ // GCC: type_info::name() returns a mangled class name,st demangle @@ -251,18 +259,18 @@ namespace // but gcc 3.3 libstc++'s implementation of demangling is broken // and fails without. - char* name = abi::__cxa_demangle(type.name(), + char* name = abi::__cxa_demangle(mangled, abi_name_buf, &abi_name_len, &status); // this call can realloc the abi_name_buf pointer (!) - return name ? name : type.name(); + return name ? name : mangled; #elif LL_WINDOWS // DevStudio: type_info::name() includes the text "class " at the start static const std::string class_prefix = "class "; - std::string name = type.name(); + std::string name = mangled; std::string::size_type p = name.find(class_prefix); if (p == std::string::npos) { @@ -271,11 +279,14 @@ namespace return name.substr(p + class_prefix.size()); -#else - return type.name(); +#else + return mangled; #endif } +} // LLError +namespace +{ std::string functionName(const std::string& preprocessor_name) { #if LL_WINDOWS diff --git a/indra/llcommon/llerror.h b/indra/llcommon/llerror.h index 63040e1772..d0ddb5e8e9 100755 --- a/indra/llcommon/llerror.h +++ b/indra/llcommon/llerror.h @@ -189,6 +189,7 @@ namespace LLError static std::ostringstream* out(); static void flush(std::ostringstream* out, char* message); static void flush(std::ostringstream*, const CallSite&); + static std::string demangle(const char* mangled); }; struct LL_COMMON_API CallSite |