30 #if defined(HAVE_EXECINFO_H) 34 #if defined(HAVE_CXXABI_H) 49 #if HAVE_GLIBC_BACKTRACE 52 size_t size = backtrace(array, 64);
53 for (
size_t i = 1; i < size; i++)
55 addresses.push_back(array[i]);
62 #if HAVE_GLIBC_BACKTRACE 63 if (addresses.empty())
68 size_t size = addresses.size();
69 char **strings = backtrace_symbols(&addresses.front(), size);
71 for (
size_t i = 0; i < size; ++i)
73 lines.push_back(strings[i]);
84 char* demangled = abi::__cxa_demangle(name.c_str(), 0, 0, &status);
107 size_t paren_pos = line.find(
'(');
108 size_t plus_pos = line.find(
'+');
109 if (paren_pos == std::string::npos || plus_pos == std::string::npos)
114 std::string name(line, paren_pos + 1, plus_pos - paren_pos - 1);
115 return line.substr(0, paren_pos + 1) +
demangleName(name) + line.substr(plus_pos);
120 V_string::const_iterator it = lines.begin();
121 V_string::const_iterator end = lines.end();
122 for (; it != end; ++it)
134 std::stringstream ss;
135 V_string::const_iterator it = demangled.begin();
136 V_string::const_iterator end = demangled.end();
137 for (; it != end; ++it)
139 ss << *it << std::endl;
CPP_COMMON_DECL void demangleBacktrace(const V_string &names, V_string &demangled)
CPP_COMMON_DECL std::string backtraceToString(const V_void &addresses)
CPP_COMMON_DECL std::string demangleName(const std::string &name)
std::string demangleBacktraceLine(const std::string &line)
std::vector< void * > V_void
CPP_COMMON_DECL std::string getBacktrace()
std::vector< std::string > V_string
CPP_COMMON_DECL void translateAddresses(const V_void &addresses, V_string &lines)