cpptrace: [Issue] MacOS Sequoia 15.1 does not show stacktraces names
For the following example on MacOS Sequoia 15.1:
#include <cpptrace/cpptrace.hpp>
#include <execinfo.h>
#include <stdio.h>
#include <stdlib.h>
void printStackTrace() {
void *callstack[128];
int frames = backtrace(callstack, 128);
char **strs = backtrace_symbols(callstack, frames);
for (int i = 0; i < frames; ++i) {
printf("%s\n", strs[i]);
}
free(strs);
}
int main() {
cpptrace::generate_trace().print();
printStackTrace();
return 0;
}
produce the following output:
$ <project_path>/cmake-build-debug/<project_name>
0 MagicSDR 0x0000000100c845a0 _Z15printStackTracev + 48
1 MagicSDR 0x0000000100c84680 main + 56
2 dyld 0x000000018e73c274 start + 2840
Stack trace (most recent call first):
#0 0x0000000100c84667 at <project_path>/cmake-build-debug/<project_name>
#1 0x000000018e73c273 at /usr/lib/dyld
As you can see printStackTrace() produce the output with function names, but the cpptrace::generate_trace().print() does not print names of functions on stacktrace
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 18 (8 by maintainers)
I have gone ahead and released 0.7.4. PRs for various package managers will be on their way shortly.
Sorry about that, I forgot libdwarf now provides an export set upstream. There’s a variable in cpptrace to turn off the cpptrace-declared export set for libdwarf,
CPPTRACE_PROVIDE_EXPORT_SET_FOR_LIBDWARF. This works for me:Ah ha! I believe this is due to https://github.com/davea42/libdwarf-code/issues/269 then, should be fixed in libdwarf 0.11.0 which is currently used in cpptrace
dev. I’ll do a cpptrace 0.7.4 release sometime soon so new libdwarf changes can be available.In the meantime,
-DCPPTRACE_LIBDWARF_REPO=https://github.com/davea42/libdwarf-code.git -DCPPTRACE_LIBDWARF_TAG=909af3e46b68335df6c4a901ddd256ffa0d193d2should be a workaround.Using Clion and
-DCMAKE_BUILD_TYPE=DebugHi, thanks for the report. I’ll take a look. How are you compiling? Execinfo.h’s
backtrace_symbolsuses dynamic export information instead of debug symbols so I’m wondering if this was compiled without debug symbols.