Skip to content

Commit ad4d87a

Browse files
MrCirdoBenBEExplorer09
committed
Add libiberty library
Co-authored-by: Benny Baumann <BenBE@geshi.org> Co-authored-by: Kang-Che Sung <explorer09@gmail.com>
1 parent 0c263f9 commit ad4d87a

2 files changed

Lines changed: 66 additions & 10 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ To install on the local system run `make install`. By default `make install` ins
147147
- default: *no*
148148
- possible values:
149149
- unwind-ptrace: use unwind-ptrace to get the backtraces
150+
* `--enable-demangling`:
151+
enable the demangling support for the backtraces
152+
- default: *no*
153+
- possible values:
154+
- libiberty: use the libiberty to demangle the name
150155

151156

152157
## Runtime dependencies:

configure.ac

Lines changed: 61 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,7 @@ if test "x$enable_backtrace" != xno; then
11701170
fi
11711171
AM_CONDITIONAL([HAVE_BACKTRACE_SCREEN], [test x"$enable_backtrace" != xno])
11721172

1173-
if test "x$enable_backtrace" = xunwind-ptrace; then
1173+
if test "x$enable_backtrace" = xunwind-ptrace -a "x$my_htop_platform" = xlinux; then
11741174
AC_MSG_CHECKING([if libunwind has unw_get_elf_filename])
11751175
AC_LINK_IFELSE(
11761176
[AC_LANG_PROGRAM(
@@ -1186,15 +1186,65 @@ if test "x$enable_backtrace" = xunwind-ptrace; then
11861186
)
11871187
fi
11881188

1189-
AC_ARG_ENABLE(
1190-
[hwloc],
1191-
[AS_HELP_STRING(
1192-
[--enable-hwloc],
1193-
[enable hwloc support for CPU affinity; disables affinity support; requires libhwloc @<:@default=no@:>@]
1194-
)],
1195-
[],
1196-
[enable_hwloc=no]
1197-
)
1189+
AC_ARG_ENABLE([demangling],
1190+
[AS_HELP_STRING([--enable-demangling],
1191+
[enable demangling support for backtraces @<:@default=check@:>@])],
1192+
[],
1193+
[enable_demangling=check])
1194+
have_libiberty=no
1195+
case $enable_demangling in
1196+
check|yes|libiberty)
1197+
AC_CHECK_LIB([iberty], [cplus_demangle], [
1198+
have_libiberty=yes
1199+
AC_DEFINE([HAVE_LIBIBERTY], [1], [Define to 1 if libiberty is found.])
1200+
LIBS="$LIBS -liberty"
1201+
], [
1202+
if test "x$enable_demangling" = xlibiberty; then
1203+
AC_MSG_ERROR([--enable-demangling specified but libiberty not found])
1204+
fi
1205+
])
1206+
1207+
if test "x$have_libiberty" = xyes; then
1208+
if ! htop_search_header_dir libiberty/demangle.h "/usr/include/libiberty"; then
1209+
have_libiberty=no
1210+
if test "x$enable_demangling" = xlibiberty; then
1211+
AC_MSG_ERROR([--enable-demangling specified but <demangle.h> not found])
1212+
fi
1213+
fi
1214+
fi
1215+
1216+
if test "x$have_libiberty" = xyes; then
1217+
enable_demangling=libiberty
1218+
fi
1219+
;;
1220+
esac
1221+
1222+
case $enable_demangling in
1223+
libiberty)
1224+
AC_DEFINE([HAVE_DEMANGLING], [1], [Define to 1 if the demangling is supported.])
1225+
;;
1226+
check)
1227+
enable_demangling=no
1228+
;;
1229+
yes)
1230+
AC_MSG_ERROR([cannot find any library for the backend supported by --enable-demangling])
1231+
;;
1232+
no)
1233+
;;
1234+
*)
1235+
AC_MSG_ERROR([bad value '$enable_demangling' for --enable-demangling])
1236+
;;
1237+
esac
1238+
1239+
if test "x$enable_backtrace" != xno && test "x$enable_demangling" = xno; then
1240+
AC_MSG_WARN([The backtrace feature is enabled, but name demangling is not.])
1241+
fi
1242+
1243+
AC_ARG_ENABLE([hwloc],
1244+
[AS_HELP_STRING([--enable-hwloc],
1245+
[enable hwloc support for CPU affinity; disables affinity support; requires libhwloc @<:@default=no@:>@])],
1246+
[],
1247+
[enable_hwloc=no])
11981248
case "$enable_hwloc" in
11991249
no)
12001250
;;
@@ -1640,6 +1690,7 @@ AC_MSG_RESULT([
16401690
affinity: $enable_affinity
16411691
unwind: $enable_unwind
16421692
backtrace: $enable_backtrace
1693+
demangling: $enable_demangling
16431694
hwloc: $enable_hwloc
16441695
debug: $enable_debug
16451696
static: $enable_static

0 commit comments

Comments
 (0)