summaryrefslogtreecommitdiff
path: root/libs/pbd/stacktrace.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2013-04-05 11:26:39 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2013-04-05 11:26:39 -0400
commit7db5d68cdb1c7b6138907cb732e913ec91212e13 (patch)
treeaf58ff4bd546b22106191dee4bac7d4999948ec7 /libs/pbd/stacktrace.cc
parent19bd6419157119b976393a0c5966b4be4c962119 (diff)
adjust demangling code a bit so that it can easily be used with typenames and not just functions in stacktraces
Diffstat (limited to 'libs/pbd/stacktrace.cc')
-rw-r--r--libs/pbd/stacktrace.cc42
1 files changed, 25 insertions, 17 deletions
diff --git a/libs/pbd/stacktrace.cc b/libs/pbd/stacktrace.cc
index ca614509a5..ead7e33e4b 100644
--- a/libs/pbd/stacktrace.cc
+++ b/libs/pbd/stacktrace.cc
@@ -35,37 +35,45 @@ PBD::trace_twb ()
#include <execinfo.h>
#include <cxxabi.h>
-std::string demangle (std::string const & l)
+static std::string
+symbol_demangle (const std::string& l)
+{
+ int status;
+
+ try {
+
+ char* realname = abi::__cxa_demangle (l.c_str(), 0, 0, &status);
+ std::string d (realname);
+ free (realname);
+ return d;
+ } catch (std::exception) {
+
+ }
+
+ return l;
+}
+
+std::string
+PBD::demangle (std::string const & l)
{
std::string::size_type const b = l.find_first_of ("(");
+
if (b == std::string::npos) {
- return l;
+ return symbol_demangle (l);
}
std::string::size_type const p = l.find_last_of ("+");
if (p == std::string::npos) {
- return l;
+ return symbol_demangle (l);
}
if ((p - b) <= 1) {
- return l;
+ return symbol_demangle (l);
}
std::string const fn = l.substr (b + 1, p - b - 1);
- int status;
- try {
-
- char* realname = abi::__cxa_demangle (fn.c_str(), 0, 0, &status);
- std::string d (realname);
- free (realname);
- return d;
-
- } catch (std::exception) {
-
- }
-
- return l;
+ return symbol_demangle (fn);
}
void