added libunwind interface support for stack frame backtracing

This commit is contained in:
hyung-hwan 2018-04-26 04:50:40 +00:00
parent deb53399a4
commit a07f943dbc
8 changed files with 216 additions and 43 deletions

View File

@ -166,8 +166,8 @@ am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/ac/ar-lib \
$(top_srcdir)/ac/compile $(top_srcdir)/ac/config.guess \ $(top_srcdir)/ac/compile $(top_srcdir)/ac/config.guess \
$(top_srcdir)/ac/config.sub $(top_srcdir)/ac/install-sh \ $(top_srcdir)/ac/config.sub $(top_srcdir)/ac/install-sh \
$(top_srcdir)/ac/ltmain.sh $(top_srcdir)/ac/missing ac/ar-lib \ $(top_srcdir)/ac/ltmain.sh $(top_srcdir)/ac/missing ac/ar-lib \
ac/compile ac/config.guess ac/config.sub ac/install-sh \ ac/compile ac/config.guess ac/config.sub ac/depcomp \
ac/ltmain.sh ac/missing ac/install-sh ac/ltmain.sh ac/missing
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION) distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir) top_distdir = $(distdir)
@ -306,6 +306,7 @@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@ SHELL = @SHELL@
STRIP = @STRIP@ STRIP = @STRIP@
UNICOWS_LIBS = @UNICOWS_LIBS@ UNICOWS_LIBS = @UNICOWS_LIBS@
UNWIND_LIBS = @UNWIND_LIBS@
VERSION = @VERSION@ VERSION = @VERSION@
abs_builddir = @abs_builddir@ abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@ abs_srcdir = @abs_srcdir@
@ -353,7 +354,6 @@ pdfdir = @pdfdir@
prefix = @prefix@ prefix = @prefix@
program_transform_name = @program_transform_name@ program_transform_name = @program_transform_name@
psdir = @psdir@ psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@ sharedstatedir = @sharedstatedir@
srcdir = @srcdir@ srcdir = @srcdir@
@ -584,7 +584,7 @@ distdir: $(DISTFILES)
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r "$(distdir)" || chmod -R a+r "$(distdir)"
dist-gzip: distdir dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz
$(am__post_remove_distdir) $(am__post_remove_distdir)
dist-bzip2: distdir dist-bzip2: distdir
@ -610,7 +610,7 @@ dist-shar: distdir
@echo WARNING: "Support for shar distribution archives is" \ @echo WARNING: "Support for shar distribution archives is" \
"deprecated." >&2 "deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz
$(am__post_remove_distdir) $(am__post_remove_distdir)
dist-zip: distdir dist-zip: distdir
@ -628,7 +628,7 @@ dist dist-all:
distcheck: dist distcheck: dist
case '$(DIST_ARCHIVES)' in \ case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \ *.tar.gz*) \
GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \ *.tar.bz2*) \
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lz*) \ *.tar.lz*) \
@ -638,7 +638,7 @@ distcheck: dist
*.tar.Z*) \ *.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \ *.shar.gz*) \
GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\
*.zip*) \ *.zip*) \
unzip $(distdir).zip ;;\ unzip $(distdir).zip ;;\
esac esac

114
configure vendored
View File

@ -653,6 +653,8 @@ HCL_SIZEOF_CHAR16_T
HCL_SIZEOF_WCHAR_T HCL_SIZEOF_WCHAR_T
ENABLE_HCLEX_FALSE ENABLE_HCLEX_FALSE
ENABLE_HCLEX_TRUE ENABLE_HCLEX_TRUE
ENABLE_LIBUNWIND_FALSE
ENABLE_LIBUNWIND_TRUE
ENABLE_LIBLTDL_FALSE ENABLE_LIBLTDL_FALSE
ENABLE_LIBLTDL_TRUE ENABLE_LIBLTDL_TRUE
ENABLE_STATIC_MODULE_FALSE ENABLE_STATIC_MODULE_FALSE
@ -667,6 +669,7 @@ PACKAGE_VERSION_MINOR
PACKAGE_VERSION_MAJOR PACKAGE_VERSION_MAJOR
QUADMATH_LIBS QUADMATH_LIBS
UNICOWS_LIBS UNICOWS_LIBS
UNWIND_LIBS
LTDL_LIBS LTDL_LIBS
DL_LIBS DL_LIBS
PTHREAD_CFLAGS PTHREAD_CFLAGS
@ -779,7 +782,6 @@ infodir
docdir docdir
oldincludedir oldincludedir
includedir includedir
runstatedir
localstatedir localstatedir
sharedstatedir sharedstatedir
sysconfdir sysconfdir
@ -818,6 +820,7 @@ enable_cxx
enable_dynamic_module enable_dynamic_module
enable_static_module enable_static_module
enable_libltdl enable_libltdl
enable_libunwind
enable_hclex enable_hclex
' '
ac_precious_vars='build_alias ac_precious_vars='build_alias
@ -872,7 +875,6 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc' sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com' sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var' localstatedir='${prefix}/var'
runstatedir='${localstatedir}/run'
includedir='${prefix}/include' includedir='${prefix}/include'
oldincludedir='/usr/include' oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@ -1125,15 +1127,6 @@ do
| -silent | --silent | --silen | --sile | --sil) | -silent | --silent | --silen | --sile | --sil)
silent=yes ;; silent=yes ;;
-runstatedir | --runstatedir | --runstatedi | --runstated \
| --runstate | --runstat | --runsta | --runst | --runs \
| --run | --ru | --r)
ac_prev=runstatedir ;;
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
| --run=* | --ru=* | --r=*)
runstatedir=$ac_optarg ;;
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;; ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@ -1271,7 +1264,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \ datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir runstatedir libdir localedir mandir
do do
eval ac_val=\$$ac_var eval ac_val=\$$ac_var
# Remove trailing slashes. # Remove trailing slashes.
@ -1424,7 +1417,6 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var] --localstatedir=DIR modifiable single-machine data [PREFIX/var]
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib] --libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include] --includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include] --oldincludedir=DIR C header files for non-gcc [/usr/include]
@ -1484,6 +1476,7 @@ Optional Features:
--enable-static-module build modules statically into the main --enable-static-module build modules statically into the main
library(default. no) library(default. no)
--enable-libltdl use libltdl(default. no) --enable-libltdl use libltdl(default. no)
--enable-libunwind use libunwind(default. no)
--enable-hclex build libhclex(default. no) --enable-hclex build libhclex(default. no)
Optional Packages: Optional Packages:
@ -18246,6 +18239,18 @@ fi
done done
for ac_header in libunwind.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "libunwind.h" "ac_cv_header_libunwind_h" "$ac_includes_default"
if test "x$ac_cv_header_libunwind_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBUNWIND_H 1
_ACEOF
fi
done
@ -18454,6 +18459,57 @@ fi
LIBS="$save_LIBS" LIBS="$save_LIBS"
if test "x${ac_cv_header_libunwind_h}" = "xyes"
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for unw_backtrace in -lunwind" >&5
$as_echo_n "checking for unw_backtrace in -lunwind... " >&6; }
if ${ac_cv_lib_unwind_unw_backtrace+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lunwind $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char unw_backtrace ();
int
main ()
{
return unw_backtrace ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_unwind_unw_backtrace=yes
else
ac_cv_lib_unwind_unw_backtrace=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_unwind_unw_backtrace" >&5
$as_echo "$ac_cv_lib_unwind_unw_backtrace" >&6; }
if test "x$ac_cv_lib_unwind_unw_backtrace" = xyes; then :
UNWIND_LIBS="-lunwind"
$as_echo "#define HAVE_UNWIND_LIB 1" >>confdefs.h
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lunicows" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lunicows" >&5
$as_echo_n "checking for main in -lunicows... " >&6; } $as_echo_n "checking for main in -lunicows... " >&6; }
if ${ac_cv_lib_unicows_main+:} false; then : if ${ac_cv_lib_unicows_main+:} false; then :
@ -21148,6 +21204,34 @@ else
fi fi
# Check whether --enable-libunwind was given.
if test "${enable_libunwind+set}" = set; then :
enableval=$enable_libunwind; enable_libunwind_is=$enableval
else
enable_libunwind_is=no
fi
if test "x${enable_libunwind_is}" = "xyes"
then
if test "x${ac_cv_header_unwind_h}" = "xyes" -a "${UNWIND_LIBS}" != ""
then
$as_echo "#define HCL_ENABLE_LIBUNWIND /**/" >>confdefs.h
else
enable_libunwind_is="no"
fi
fi
if test "x${enable_libunwind_is}" = "xyes"; then
ENABLE_LIBUNWIND_TRUE=
ENABLE_LIBUNWIND_FALSE='#'
else
ENABLE_LIBUNWIND_TRUE='#'
ENABLE_LIBUNWIND_FALSE=
fi
# Check whether --enable-hclex was given. # Check whether --enable-hclex was given.
if test "${enable_hclex+set}" = set; then : if test "${enable_hclex+set}" = set; then :
enableval=$enable_hclex; enable_hclex_is=$enableval enableval=$enable_hclex; enable_hclex_is=$enableval
@ -21363,6 +21447,10 @@ if test -z "${ENABLE_LIBLTDL_TRUE}" && test -z "${ENABLE_LIBLTDL_FALSE}"; then
as_fn_error $? "conditional \"ENABLE_LIBLTDL\" was never defined. as_fn_error $? "conditional \"ENABLE_LIBLTDL\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5 Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi fi
if test -z "${ENABLE_LIBUNWIND_TRUE}" && test -z "${ENABLE_LIBUNWIND_FALSE}"; then
as_fn_error $? "conditional \"ENABLE_LIBUNWIND\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${ENABLE_HCLEX_TRUE}" && test -z "${ENABLE_HCLEX_FALSE}"; then if test -z "${ENABLE_HCLEX_TRUE}" && test -z "${ENABLE_HCLEX_FALSE}"; then
as_fn_error $? "conditional \"ENABLE_HCLEX\" was never defined. as_fn_error $? "conditional \"ENABLE_HCLEX\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5 Usually this means the macro was only invoked conditionally." "$LINENO" 5

View File

@ -122,6 +122,7 @@ AC_CHECK_HEADERS([stddef.h wchar.h wctype.h errno.h signal.h fcntl.h dirent.h])
AC_CHECK_HEADERS([time.h sys/time.h utime.h spawn.h execinfo.h ucontext.h]) AC_CHECK_HEADERS([time.h sys/time.h utime.h spawn.h execinfo.h ucontext.h])
AC_CHECK_HEADERS([dlfcn.h ltdl.h sys/mman.h sys/uio.h]) AC_CHECK_HEADERS([dlfcn.h ltdl.h sys/mman.h sys/uio.h])
AC_CHECK_HEADERS([sys/devpoll.h sys/epoll.h poll.h]) AC_CHECK_HEADERS([sys/devpoll.h sys/epoll.h poll.h])
AC_CHECK_HEADERS([libunwind.h])
dnl check data types dnl check data types
dnl AC_CHECK_TYPE([wchar_t], dnl AC_CHECK_TYPE([wchar_t],
@ -161,6 +162,17 @@ AC_SEARCH_LIBS([lt_dlopen], [ltdl], [
LIBS="$save_LIBS" LIBS="$save_LIBS"
AC_SUBST(LTDL_LIBS) AC_SUBST(LTDL_LIBS)
if test "x${ac_cv_header_libunwind_h}" = "xyes"
then
AC_CHECK_LIB([unwind], [unw_backtrace],
[
UNWIND_LIBS="-lunwind"
AC_DEFINE([HAVE_UNWIND_LIB], [1], [libunwind is available])
]
)
AC_SUBST(UNWIND_LIBS)
fi
dnl check is the import library for unicows.dll exists dnl check is the import library for unicows.dll exists
dnl this check doesn't look for a particular symbol dnl this check doesn't look for a particular symbol
dnl but for the symbol 'main' since i want to check dnl but for the symbol 'main' since i want to check
@ -643,6 +655,23 @@ then
fi fi
AM_CONDITIONAL(ENABLE_LIBLTDL, test "x${enable_libltdl_is}" = "xyes") AM_CONDITIONAL(ENABLE_LIBLTDL, test "x${enable_libltdl_is}" = "xyes")
dnl ===== enable-libunwind =====
AC_ARG_ENABLE([libunwind],
[AS_HELP_STRING([--enable-libunwind],[use libunwind(default. no)])],
enable_libunwind_is=$enableval,
enable_libunwind_is=no
)
if test "x${enable_libunwind_is}" = "xyes"
then
if test "x${ac_cv_header_unwind_h}" = "xyes" -a "${UNWIND_LIBS}" != ""
then
AC_DEFINE([HCL_ENABLE_LIBUNWIND],[],[use libunwind for backtracing stack frames])
else
enable_libunwind_is="no"
fi
fi
AM_CONDITIONAL(ENABLE_LIBUNWIND, test "x${enable_libunwind_is}" = "xyes")
dnl ===== enable-hclex ===== dnl ===== enable-hclex =====
AC_ARG_ENABLE([hclex], AC_ARG_ENABLE([hclex],
[AS_HELP_STRING([--enable-hclex],[build libhclex(default. no)])], [AS_HELP_STRING([--enable-hclex],[build libhclex(default. no)])],

View File

@ -28,6 +28,9 @@ else
LIBADD_LIB_COMMON += $(DL_LIBS) LIBADD_LIB_COMMON += $(DL_LIBS)
endif endif
if ENABLE_LIBUNWIND
LIBADD_LIB_COMMON += $(UNWIND_LIBS)
endif
pkgincludedir = $(includedir) pkgincludedir = $(includedir)
pkglibdir = $(libdir) pkglibdir = $(libdir)

View File

@ -90,15 +90,16 @@ build_triplet = @build@
host_triplet = @host@ host_triplet = @host@
@ENABLE_LIBLTDL_TRUE@am__append_1 = $(LTDL_LIBS) @ENABLE_LIBLTDL_TRUE@am__append_1 = $(LTDL_LIBS)
@ENABLE_LIBLTDL_FALSE@am__append_2 = $(DL_LIBS) @ENABLE_LIBLTDL_FALSE@am__append_2 = $(DL_LIBS)
@ENABLE_STATIC_MODULE_TRUE@am__append_3 = -lhcl-arr -lhcl-dic \ @ENABLE_LIBUNWIND_TRUE@am__append_3 = $(UNWIND_LIBS)
@ENABLE_STATIC_MODULE_TRUE@am__append_4 = -lhcl-arr -lhcl-dic \
@ENABLE_STATIC_MODULE_TRUE@ -lhcl-str @ENABLE_STATIC_MODULE_TRUE@ -lhcl-str
@ENABLE_STATIC_MODULE_TRUE@am__append_4 = $(abs_builddir)/../mod/libhcl-arr.la \ @ENABLE_STATIC_MODULE_TRUE@am__append_5 = $(abs_builddir)/../mod/libhcl-arr.la \
@ENABLE_STATIC_MODULE_TRUE@ $(abs_builddir)/../mod/libhcl-dic.la \ @ENABLE_STATIC_MODULE_TRUE@ $(abs_builddir)/../mod/libhcl-dic.la \
@ENABLE_STATIC_MODULE_TRUE@ $(abs_builddir)/../mod/libhcl-str.la @ENABLE_STATIC_MODULE_TRUE@ $(abs_builddir)/../mod/libhcl-str.la
bin_PROGRAMS = hcl$(EXEEXT) $(am__EXEEXT_1) bin_PROGRAMS = hcl$(EXEEXT) $(am__EXEEXT_1)
@ENABLE_HCLEX_TRUE@am__append_5 = libhclex.la @ENABLE_HCLEX_TRUE@am__append_6 = libhclex.la
@ENABLE_HCLEX_TRUE@am__append_6 = hcl-c.h hcl-s.h hcl-tmr.h hcl-xutl.h hcl-json.h @ENABLE_HCLEX_TRUE@am__append_7 = hcl-c.h hcl-s.h hcl-tmr.h hcl-xutl.h hcl-json.h
@ENABLE_HCLEX_TRUE@am__append_7 = hcls hclc hclj @ENABLE_HCLEX_TRUE@am__append_8 = hcls hclc hclj
subdir = lib subdir = lib
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
@ -148,8 +149,9 @@ LTLIBRARIES = $(pkglib_LTLIBRARIES)
am__DEPENDENCIES_1 = am__DEPENDENCIES_1 =
@ENABLE_LIBLTDL_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) @ENABLE_LIBLTDL_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
@ENABLE_LIBLTDL_FALSE@am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1) @ENABLE_LIBLTDL_FALSE@am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1)
am__DEPENDENCIES_4 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \ @ENABLE_LIBUNWIND_TRUE@am__DEPENDENCIES_4 = $(am__DEPENDENCIES_1)
$(am__DEPENDENCIES_3) am__DEPENDENCIES_5 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \
$(am__DEPENDENCIES_3) $(am__DEPENDENCIES_4)
am_libhcl_la_OBJECTS = libhcl_la-bigint.lo libhcl_la-comp.lo \ am_libhcl_la_OBJECTS = libhcl_la-bigint.lo libhcl_la-comp.lo \
libhcl_la-debug.lo libhcl_la-decode.lo libhcl_la-dic.lo \ libhcl_la-debug.lo libhcl_la-decode.lo libhcl_la-dic.lo \
libhcl_la-err.lo libhcl_la-exec.lo libhcl_la-gc.lo \ libhcl_la-err.lo libhcl_la-exec.lo libhcl_la-gc.lo \
@ -370,6 +372,7 @@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@ SHELL = @SHELL@
STRIP = @STRIP@ STRIP = @STRIP@
UNICOWS_LIBS = @UNICOWS_LIBS@ UNICOWS_LIBS = @UNICOWS_LIBS@
UNWIND_LIBS = @UNWIND_LIBS@
VERSION = @VERSION@ VERSION = @VERSION@
abs_builddir = @abs_builddir@ abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@ abs_srcdir = @abs_srcdir@
@ -417,7 +420,6 @@ pdfdir = @pdfdir@
prefix = @prefix@ prefix = @prefix@
program_transform_name = @program_transform_name@ program_transform_name = @program_transform_name@
psdir = @psdir@ psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@ sharedstatedir = @sharedstatedir@
srcdir = @srcdir@ srcdir = @srcdir@
@ -441,10 +443,11 @@ CPPFLAGS_ALL_COMMON = \
################################################## ##################################################
CPPFLAGS_LIB_COMMON = $(CPPFLAGS_ALL_COMMON) CPPFLAGS_LIB_COMMON = $(CPPFLAGS_ALL_COMMON)
LDFLAGS_LIB_COMMON = $(LDFLAGS_ALL_COMMON) -version-info 1:0:0 -no-undefined LDFLAGS_LIB_COMMON = $(LDFLAGS_ALL_COMMON) -version-info 1:0:0 -no-undefined
LIBADD_LIB_COMMON = $(LIBM) $(am__append_1) $(am__append_2) LIBADD_LIB_COMMON = $(LIBM) $(am__append_1) $(am__append_2) \
$(am__append_3)
pkginclude_HEADERS = hcl.h hcl-cmn.h hcl-opt.h hcl-rbt.h hcl-utl.h \ pkginclude_HEADERS = hcl.h hcl-cmn.h hcl-opt.h hcl-rbt.h hcl-utl.h \
$(am__append_6) $(am__append_7)
pkglib_LTLIBRARIES = libhcl.la $(am__append_5) pkglib_LTLIBRARIES = libhcl.la $(am__append_6)
libhcl_la_SOURCES = \ libhcl_la_SOURCES = \
hcl.h \ hcl.h \
hcl-cmn.h \ hcl-cmn.h \
@ -478,8 +481,8 @@ libhcl_la_SOURCES = \
libhcl_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON) libhcl_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
libhcl_la_LDFLAGS = $(LDFLAGS_LIB_COMMON) libhcl_la_LDFLAGS = $(LDFLAGS_LIB_COMMON)
libhcl_la_LIBADD = $(LIBADD_LIB_COMMON) $(am__append_3) libhcl_la_LIBADD = $(LIBADD_LIB_COMMON) $(am__append_4)
libhcl_la_DEPENDENCIES = $(am__append_4) libhcl_la_DEPENDENCIES = $(am__append_5)
hcl_SOURCES = main.c hcl_SOURCES = main.c
hcl_CPPFLAGS = $(CPPFLAGS_LIB_COMMON) hcl_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
hcl_LDFLAGS = $(LDFLAGS_LIB_COMMON) hcl_LDFLAGS = $(LDFLAGS_LIB_COMMON)

View File

@ -26,6 +26,10 @@
#include "hcl-prv.h" #include "hcl-prv.h"
#if defined(HCL_ENABLE_LIBUNWIND)
# include <libunwind.h>
#endif
static hcl_ooch_t errstr_0[] = {'n','o',' ','e','r','r','o','r','\0'}; static hcl_ooch_t errstr_0[] = {'n','o',' ','e','r','r','o','r','\0'};
static hcl_ooch_t errstr_1[] = {'g','e','n','e','r','i','c',' ','e','r','r','o','r','\0'}; static hcl_ooch_t errstr_1[] = {'g','e','n','e','r','i','c',' ','e','r','r','o','r','\0'};
static hcl_ooch_t errstr_2[] = {'n','o','t',' ','i','m','p','l','e','m','e','n','t','e','d','\0'}; static hcl_ooch_t errstr_2[] = {'n','o','t',' ','i','m','p','l','e','m','e','n','t','e','d','\0'};
@ -472,22 +476,45 @@ void hcl_setsynerrufmt (hcl_t* hcl, hcl_synerrnum_t num, const hcl_ioloc_t* loc,
} }
} }
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
* ASSERTION FAILURE HANDLERsemaphore heap full * STACK FRAME BACKTRACE
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
#if defined(HCL_ENABLE_LIBUNWIND)
void hcl_assertfailed (hcl_t* hcl, const hcl_bch_t* expr, const hcl_bch_t* file, hcl_oow_t line) static void backtrace_stack_frames (hcl_t* hcl)
{
unw_cursor_t cursor;
unw_context_t context;
unw_getcontext(&context);
unw_init_local(&cursor, &context);
int n=0;
while (unw_step(&cursor))
{
unw_word_t ip, sp, off;
unw_get_reg (&cursor, UNW_REG_IP, &ip);
unw_get_reg (&cursor, UNW_REG_SP, &sp);
char symbol[256];
if (!unw_get_proc_name(&cursor, symbol, HCL_COUNTOF(symbol), &off))
{
hcl_copy_bcstr (symbol, "<unknown>");
}
hcl_logbfmt (hcl, HCL_LOG_UNTYPED | HCL_LOG_DEBUG,
"#%-2d 0x%016p p=0x%016p %s + 0x%zu\n",
++n, (void*)ip, (void*)sp, symbol, (hcl_oow_t)off);
}
}
#elif defined(HAVE_BACKTRACE)
static void backtrace_stack_frames (hcl_t* hcl)
{ {
#if defined(HAVE_BACKTRACE)
void* btarray[128]; void* btarray[128];
hcl_oow_t btsize; hcl_oow_t btsize;
char** btsyms; char** btsyms;
#endif
hcl_logbfmt (hcl, HCL_LOG_UNTYPED | HCL_LOG_FATAL, "ASSERTION FAILURE: %s at %s:%zu\n", expr, file, line);
#if defined(HAVE_BACKTRACE)
btsize = backtrace (btarray, HCL_COUNTOF(btarray)); btsize = backtrace (btarray, HCL_COUNTOF(btarray));
btsyms = backtrace_symbols (btarray, btsize); btsyms = backtrace_symbols (btarray, btsize);
if (btsyms) if (btsyms)
@ -501,8 +528,22 @@ void hcl_assertfailed (hcl_t* hcl, const hcl_bch_t* expr, const hcl_bch_t* file,
} }
free (btsyms); free (btsyms);
} }
}
#else
static void backtrace_stack_frames (hcl_t* hcl)
{
/* do nothing. not supported */
}
#endif #endif
/* --------------------------------------------------------------------------
* ASSERTION FAILURE HANDLERsemaphore heap full
* -------------------------------------------------------------------------- */
void hcl_assertfailed (hcl_t* hcl, const hcl_bch_t* expr, const hcl_bch_t* file, hcl_oow_t line)
{
hcl_logbfmt (hcl, HCL_LOG_UNTYPED | HCL_LOG_FATAL, "ASSERTION FAILURE: %s at %s:%zu\n", expr, file, line);
backtrace_stack_frames (hcl);
#if defined(_WIN32) #if defined(_WIN32)
ExitProcess (249); ExitProcess (249);

View File

@ -81,6 +81,9 @@
/* Define to 1 if you have the `isatty' function. */ /* Define to 1 if you have the `isatty' function. */
#undef HAVE_ISATTY #undef HAVE_ISATTY
/* Define to 1 if you have the <libunwind.h> header file. */
#undef HAVE_LIBUNWIND_H
/* Define to 1 if you have the `log10q' function. */ /* Define to 1 if you have the `log10q' function. */
#undef HAVE_LOG10Q #undef HAVE_LOG10Q
@ -213,6 +216,9 @@
/* Define to 1 if you have the <unistd.h> header file. */ /* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H #undef HAVE_UNISTD_H
/* libunwind is available */
#undef HAVE_UNWIND_LIB
/* Define to 1 if you have the `usleep' function. */ /* Define to 1 if you have the `usleep' function. */
#undef HAVE_USLEEP #undef HAVE_USLEEP
@ -264,6 +270,9 @@
/* use libltdl when loading a dynamic module */ /* use libltdl when loading a dynamic module */
#undef HCL_ENABLE_LIBLTDL #undef HCL_ENABLE_LIBLTDL
/* use libunwind for backtracing stack frames */
#undef HCL_ENABLE_LIBUNWIND
/* link modules statically into the main library */ /* link modules statically into the main library */
#undef HCL_ENABLE_STATIC_MODULE #undef HCL_ENABLE_STATIC_MODULE

View File

@ -329,6 +329,7 @@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@ SHELL = @SHELL@
STRIP = @STRIP@ STRIP = @STRIP@
UNICOWS_LIBS = @UNICOWS_LIBS@ UNICOWS_LIBS = @UNICOWS_LIBS@
UNWIND_LIBS = @UNWIND_LIBS@
VERSION = @VERSION@ VERSION = @VERSION@
abs_builddir = @abs_builddir@ abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@ abs_srcdir = @abs_srcdir@
@ -376,7 +377,6 @@ pdfdir = @pdfdir@
prefix = @prefix@ prefix = @prefix@
program_transform_name = @program_transform_name@ program_transform_name = @program_transform_name@
psdir = @psdir@ psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@ sharedstatedir = @sharedstatedir@
srcdir = @srcdir@ srcdir = @srcdir@