37void wxCrashPrint::Report() {
39 wxString appname = wxTheApp->GetAppName();
43 btCount = backtrace(m_btBuffer, maxBtCount);
45 wxPrintf(
"\n%s: Backtrace could not be created\n", appname.c_str());
47 m_btStrings = backtrace_symbols(m_btBuffer, btCount);
49 wxPrintf(
"\n%s: Backtrace could not get symbols\n", appname.c_str());
53 wxPrintf(
"\n*** %s (%s) crashed ***, see backtrace!\n", appname.c_str(),
58 wxString cur, addr, func, addrs;
62 for (
int i = 0; i < btCount; ++i) {
63 cur = wxString::FromAscii(m_btStrings[i]);
64 pos1 = cur.rfind(
'[');
65 pos2 = cur.rfind(
']');
66 if ((pos1 != wxString::npos) && (pos2 != wxString::npos)) {
67 addr = cur.substr(pos1 + 1, pos2 - pos1 - 1);
68 addrs.Append(addr +
" ");
70 pos1 = cur.rfind(
"_Z");
71 pos2 = cur.rfind(
'+');
72 if (pos2 == wxString::npos) pos2 = cur.rfind(
')');
73 if (pos1 != wxString::npos) {
74 func = cur.substr(pos1, pos2 - pos1);
75 func = wxString::FromAscii(
76 abi::__cxa_demangle(func.mb_str(), 0, 0, &status));
78 pos1 = cur.rfind(
'(');
79 if (pos1 != wxString::npos) {
80 func = cur.substr(pos1 + 1, pos2 - pos1 - 1);
82 pos2 = cur.rfind(
'[');
83 func = cur.substr(0, pos2 - 1);
86 lines.Add(addr +
" in " + func);
87 if (func ==
"main")
break;
91 wxString cmd = wxString::Format(
"addr2line -e /proc/%d/exe -s ", getpid());
93 if (wxExecute(cmd + addrs, fnames) != -1) {
94 for (
size_t i = 0; i < fnames.GetCount(); ++i) {
95 wxPrintf(
"%s at %s\n", lines[i].c_str(), fnames[i].c_str());
98 for (
size_t i = 0; i < lines.GetCount(); ++i) {
99 wxPrintf(
"%s\n", lines[i].c_str());
wxCrashPrint(int flags=0, const wxString &fname=wxEmptyString)
constructor
Dump debug info on crash.