On FreeBSD backtrace is not part of libc and depends on libexecinfo being
available. Instead of using manual checks we can use the builtin CMake
module FindBacktrace.cmake to detect availability of backtrace() in a
portable way.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
Comment Actions
Does NetBSD need it too?
Backtrace seems to work for me..
(lldb) bt * thread #1, stop reason = step over * frame #0: 0x00007816c08f3eaf libc.so.12`fopen(file="", mode="") at fopen.c:116 frame #1: 0x0000000096e0b0d2 phantasia`main at main.c:317 frame #2: 0x0000000096e0b047 phantasia`main(argc=1, argv=0x00007f7fff162b48) at main.c:95 frame #3: 0x0000000096e0203b phantasia`___start + 229
Comment Actions
It's probably worth having Joerg look at this, as I believe a similar fix is needed on NetBSD.
Comment Actions
Right, it's no LLDB....
For detecting libexecinfo please go for: Backtrace_LIBRARY It will handle FreeBSD and NetBSD
Comment Actions
I noticed that the backtraces are not particularly useful on FreeBSD, they always look like this (even when I disable sigaltstack()):
#0 0x000000080183d35c llvm::sys::PrintStackTrace(llvm::raw_ostream&) /exports/users/alr48/sources/llvm-upstream/lib/Support/Unix/Signals.inc:399:11 #1 0x000000080183d799 PrintStackTraceSignalHandler(void*) /exports/users/alr48/sources/llvm-upstream/lib/Support/Unix/Signals.inc:463:1 #2 0x000000080183a797 llvm::sys::RunSignalHandlers(void) /exports/users/alr48/sources/llvm-upstream/lib/Support/Signals.cpp:45:5 #3 0x000000080183da0a SignalHandler(int) /exports/users/alr48/sources/llvm-upstream/lib/Support/Unix/Signals.inc:253:1 #4 0x0000000801aa778f (/lib/libthr.so.3+0xe78f) #5 0x0000000801aa6d6f (/lib/libthr.so.3+0xdd6f)
I hacked around this issue by printing the stacktrace prior to calling abort but there must be a better solution.
Comment Actions
Build for me:
NetBSD chieftec 7.99.66 NetBSD 7.99.66 (GENERIC) #6: Wed Mar 29 21:21:19 CEST 2017 root@chieftec:/public/netbsd-root/sys/arch/amd64/compile/GENERIC amd64
$ grep -i backtrace CMakeCache.txt //Header providing backtrace(3) facility Backtrace_HEADER:STRING=execinfo.h Backtrace_INCLUDE_DIR:PATH=/usr/include Backtrace_LIBRARY:FILEPATH=/usr/lib/libexecinfo.so //Enable embedding backtraces on crash. LLVM_ENABLE_BACKTRACES:BOOL=ON //ADVANCED property for variable: Backtrace_HEADER Backtrace_HEADER-ADVANCED:INTERNAL=1 //ADVANCED property for variable: Backtrace_INCLUDE_DIR Backtrace_INCLUDE_DIR-ADVANCED:INTERNAL=1 //ADVANCED property for variable: Backtrace_LIBRARY Backtrace_LIBRARY-ADVANCED:INTERNAL=1 //Details about finding Backtrace FIND_PACKAGE_MESSAGE_DETAILS_Backtrace:INTERNAL=[/usr/lib/libexecinfo.so][/usr/include][v()] //Have symbol _Unwind_Backtrace HAVE__UNWIND_BACKTRACE:INTERNAL=1 //Have symbol backtrace _Backtrace_SYM_FOUND:INTERNAL=