mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
demangle names of call stack, thx to JM for the <cxxabi.h> tip
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38473 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
6c9bacc541
commit
56712287a6
@ -28,6 +28,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <execinfo.h>
|
||||
#include <cxxabi.h>
|
||||
#endif
|
||||
|
||||
|
||||
@ -265,7 +266,27 @@ void Debug::printCallStack()
|
||||
char** messages = backtrace_symbols(array, size);
|
||||
|
||||
for (size_t i = 0; i < size && messages != NULL; i++) {
|
||||
fprintf(stderr, "[LyX's bt]: (%d) %s\n", i, messages[i]);
|
||||
std::string orig(messages[i]);
|
||||
// extract mangled: bin/lyx2.0(_ZN3lyx7support7packageEv+0x32) [0x8a2e02b]
|
||||
char* mangled = 0;
|
||||
for (char *p = messages[i]; *p; ++p) {
|
||||
if (*p == '(') {
|
||||
*p = 0;
|
||||
mangled = p + 1;
|
||||
} else if (*p == '+') {
|
||||
*p = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int err = 0;
|
||||
char* demangled = abi::__cxa_demangle(mangled, 0, 0, &err);
|
||||
if (err == 0) {
|
||||
fprintf(stderr, "[bt]: (%d) %s %s\n", i, messages[i], demangled);
|
||||
free((void*)demangled);
|
||||
} else {
|
||||
fprintf(stderr, "[bt]: (%d) %s\n", i, orig.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user