Use libunwind for printing backtrace

This commit is contained in:
Christian Göttsche
2021-05-16 20:45:09 +02:00
committed by BenBE
parent 29983ff83a
commit 29e1fcfa05
2 changed files with 101 additions and 12 deletions

View File

@ -253,6 +253,7 @@ AC_SEARCH_LIBS([clock_gettime], [rt])
AC_CHECK_FUNCS([ \
clock_gettime \
dladdr \
faccessat \
fstatat \
host_get_clock_service \
@ -261,9 +262,6 @@ AC_CHECK_FUNCS([ \
readlinkat \
])
# Add -lexecinfo if needed
AC_SEARCH_LIBS([backtrace], [execinfo])
if test "$my_htop_platform" = darwin; then
AC_CHECK_FUNCS([mach_timebase_info])
fi
@ -409,6 +407,36 @@ if test "x$enable_affinity" = xyes; then
fi
AC_ARG_ENABLE([unwind],
[AS_HELP_STRING([--enable-unwind],
[enable unwind support for printing backtraces; requires libunwind @<:@default=check@:>@])],
[],
[enable_unwind=check])
case "$enable_unwind" in
check)
enable_unwind=yes
if test "$enable_static" = yes; then
AC_CHECK_LIB([lzma], [lzma_index_buffer_decode])
fi
AC_CHECK_LIB([unwind], [backtrace], [], [enable_unwind=no])
AC_CHECK_HEADERS([libunwind.h], [], [enable_unwind=no])
;;
no)
;;
yes)
AC_CHECK_LIB([unwind], [backtrace], [], [AC_MSG_ERROR([can not find required library libunwind])])
AC_CHECK_HEADERS([libunwind.h], [], [AC_MSG_ERROR([can not find require header file libunwind.h])])
;;
*)
AC_MSG_ERROR([bad value '$enable_unwind' for --enable-unwind])
;;
esac
if test "x$enable_unwind" = xno; then
# Fall back to backtrace(3) and add -lexecinfo if needed
AC_SEARCH_LIBS([backtrace], [execinfo])
fi
AC_ARG_ENABLE([hwloc],
[AS_HELP_STRING([--enable-hwloc],
[enable hwloc support for CPU affinity; disables affinity support; requires libhwloc @<:@default=no@:>@])],
@ -426,6 +454,7 @@ case "$enable_hwloc" in
;;
esac
AC_ARG_WITH([os-release],
[AS_HELP_STRING([--with-os-release=FILE],
[location of an os-release file @<:@default=/etc/os-release@:>@])],
@ -715,6 +744,7 @@ AC_MSG_RESULT([
(Linux) capabilities: $enable_capabilities
unicode: $enable_unicode
affinity: $enable_affinity
unwind: $enable_unwind
hwloc: $enable_hwloc
debug: $enable_debug
static: $enable_static