21 #include <senf/config.hh> 27 #include <boost/regex.hpp> 37 char ** symbols (::backtrace_symbols(backtrace, numEntries));
38 if (symbols == NULL) {
39 os <<
"error on translating backtrace addresses with ::backtrace_symbols: " << std::strerror(errno);
43 static boost::regex
const backtraceRx
44 (
"(.*)\\((.*)\\+(0x[0-9a-f]+)\\) \\[(0x[0-9a-f]+)\\]");
50 for (
int i=0; i<numEntries; ++i) {
51 std::string sym (symbols[i]);
53 if (regex_match(sym, match, backtraceRx)) {
54 std::string symbol (match[Symbol]);
56 char * demangled ( abi::__cxa_demangle(symbol.c_str(), 0, 0, &status) );
58 symbol = std::string(demangled);
61 os <<
" " << symbol <<
" + " << match[Offset]
62 <<
"\n in " << match[File] <<
" [" << match[Address] <<
"]\n";
64 else if (sym ==
"[0xffffe410]")
65 os <<
" __kernel_vsyscall [0xffffe410]\n";
66 else if (sym ==
"[0xffffe420]")
67 os <<
" __kernel_sigreturn [0xffffe410]\n";
68 else if (sym ==
"[0xffffe440]")
69 os <<
" __kernel_rt_sigreturn [0xffffe440]\n";
71 os <<
" " << sym <<
"\n";
75 os <<
"no backtrace available please compile SENF without final=1\n";
83 SENF_SCOPED_BUFFER(
void*, entries, numEntries);
84 int n ( ::
backtrace(entries, numEntries) );
void backtrace(std::ostream &os, int numEntries)
Write a backtrace to os.
void formatBacktrace(std::ostream &os, void **backtrace, int numEntries)
Format a given backtrace.