backward-cpp
backward-cpp copied to clipboard
No line number information printed on Mac OS X
Description of issue
Neither automatic (linking with backward.cpp
and printing a stack trace on SEGV) or manual (programmatically using StackTrace
and TraceResolver
) produce line numbers, even when compiling with -O0 -g
. Verified on Catalina and Monterey, clang 12 and 13, x86 and M1. I'm not sure if this is a known limitation on Mac OS X.
To reproduce
Compile this program as testme.cpp
with the command line clang++ -O0 -g -std=c++17 testme.cpp backward.cpp
, then run a.out
:
void baz() {
int * p = nullptr;
*p = 42;
}
void bar() {
baz();
}
void foo() {
bar();
}
int main() {
foo();
}
Actual output
Stack trace (most recent call last):
#8 Object "a.out", at 0x1048da83b, in main + 11
#7 Object "a.out", at 0x1048da827, in foo() + 11
#6 Object "a.out", at 0x1048da813, in bar() + 11
#5 Object "libsystem_platform.dylib", at 0x19b63c4e3, in _sigtramp + 55
#4 Object "a.out", at 0x1048dbb27, in backward::SignalHandling::sig_handler(int, __siginfo*, void*) + 39
#3 Object "a.out", at 0x1048dbdb7, in backward::SignalHandling::handleSignal(int, __siginfo*, void*) + 95
#2 Object "a.out", at 0x1048dbeb3, in backward::StackTraceImpl<backward::system_tag::darwin_tag>::load_from(void*, unsigned long, void*, void*) + 59
#1 Object "a.out", at 0x1048dbfff, in backward::StackTraceImpl<backward::system_tag::darwin_tag>::load_here(unsigned long, void*, void*) + 119
#0 Object "a.out", at 0x1048dd907, in unsigned long backward::details::unwind<backward::StackTraceImpl<backward::system_tag::darwin_tag>::callback>(backward::StackTraceImpl<backward::system_tag::darwin_tag>::callback, unsigned long) + 39
Expected output
Line numbers for each frame.
I also got such a problem, by installing binutils-dev
on ubuntu, the lines can be shown, but on Mac OS X not.
I have the same issue on my 2023 M2 macbook pro