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, 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)
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;
std::string demangleBacktraceLine(const std::string &line)
GLuint const GLchar * name
CPP_COMMON_DECL std::string demangleName(const std::string &name)
CPP_COMMON_DECL std::string backtraceToString(const V_void &addresses)
CPP_COMMON_DECL std::string getBacktrace()
std::vector< std::string > V_string
GLsizei const GLchar *const * string
status
Defines return codes that SDK interfaces use. Negative values indicate errors, a zero value indicates...
CPP_COMMON_DECL void demangleBacktrace(const V_string &names, V_string &demangled)
GLsizei const GLchar *const * strings
CPP_COMMON_DECL void translateAddresses(const V_void &addresses, V_string &lines)
std::vector< void * > V_void