added libunwind interface support for stack frame backtracing
This commit is contained in:
		| @ -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/config.sub $(top_srcdir)/ac/install-sh \ | ||||
| 	$(top_srcdir)/ac/ltmain.sh $(top_srcdir)/ac/missing ac/ar-lib \ | ||||
| 	ac/compile ac/config.guess ac/config.sub ac/install-sh \ | ||||
| 	ac/ltmain.sh ac/missing | ||||
| 	ac/compile ac/config.guess ac/config.sub ac/depcomp \ | ||||
| 	ac/install-sh ac/ltmain.sh ac/missing | ||||
| DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) | ||||
| distdir = $(PACKAGE)-$(VERSION) | ||||
| top_distdir = $(distdir) | ||||
| @ -306,6 +306,7 @@ SET_MAKE = @SET_MAKE@ | ||||
| SHELL = @SHELL@ | ||||
| STRIP = @STRIP@ | ||||
| UNICOWS_LIBS = @UNICOWS_LIBS@ | ||||
| UNWIND_LIBS = @UNWIND_LIBS@ | ||||
| VERSION = @VERSION@ | ||||
| abs_builddir = @abs_builddir@ | ||||
| abs_srcdir = @abs_srcdir@ | ||||
| @ -353,7 +354,6 @@ pdfdir = @pdfdir@ | ||||
| prefix = @prefix@ | ||||
| program_transform_name = @program_transform_name@ | ||||
| psdir = @psdir@ | ||||
| runstatedir = @runstatedir@ | ||||
| sbindir = @sbindir@ | ||||
| sharedstatedir = @sharedstatedir@ | ||||
| srcdir = @srcdir@ | ||||
| @ -584,7 +584,7 @@ distdir: $(DISTFILES) | ||||
| 	  ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ | ||||
| 	|| chmod -R a+r "$(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) | ||||
|  | ||||
| dist-bzip2: distdir | ||||
| @ -610,7 +610,7 @@ dist-shar: distdir | ||||
| 	@echo WARNING: "Support for shar distribution archives is" \ | ||||
| 	               "deprecated." >&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) | ||||
|  | ||||
| dist-zip: distdir | ||||
| @ -628,7 +628,7 @@ dist dist-all: | ||||
| distcheck: dist | ||||
| 	case '$(DIST_ARCHIVES)' in \ | ||||
| 	*.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*) \ | ||||
| 	  bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ | ||||
| 	*.tar.lz*) \ | ||||
| @ -638,7 +638,7 @@ distcheck: dist | ||||
| 	*.tar.Z*) \ | ||||
| 	  uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ | ||||
| 	*.shar.gz*) \ | ||||
| 	  GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ | ||||
| 	  eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ | ||||
| 	*.zip*) \ | ||||
| 	  unzip $(distdir).zip ;;\ | ||||
| 	esac | ||||
|  | ||||
							
								
								
									
										114
									
								
								hcl/configure
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										114
									
								
								hcl/configure
									
									
									
									
										vendored
									
									
								
							| @ -653,6 +653,8 @@ HCL_SIZEOF_CHAR16_T | ||||
| HCL_SIZEOF_WCHAR_T | ||||
| ENABLE_HCLEX_FALSE | ||||
| ENABLE_HCLEX_TRUE | ||||
| ENABLE_LIBUNWIND_FALSE | ||||
| ENABLE_LIBUNWIND_TRUE | ||||
| ENABLE_LIBLTDL_FALSE | ||||
| ENABLE_LIBLTDL_TRUE | ||||
| ENABLE_STATIC_MODULE_FALSE | ||||
| @ -667,6 +669,7 @@ PACKAGE_VERSION_MINOR | ||||
| PACKAGE_VERSION_MAJOR | ||||
| QUADMATH_LIBS | ||||
| UNICOWS_LIBS | ||||
| UNWIND_LIBS | ||||
| LTDL_LIBS | ||||
| DL_LIBS | ||||
| PTHREAD_CFLAGS | ||||
| @ -779,7 +782,6 @@ infodir | ||||
| docdir | ||||
| oldincludedir | ||||
| includedir | ||||
| runstatedir | ||||
| localstatedir | ||||
| sharedstatedir | ||||
| sysconfdir | ||||
| @ -818,6 +820,7 @@ enable_cxx | ||||
| enable_dynamic_module | ||||
| enable_static_module | ||||
| enable_libltdl | ||||
| enable_libunwind | ||||
| enable_hclex | ||||
| ' | ||||
|       ac_precious_vars='build_alias | ||||
| @ -872,7 +875,6 @@ datadir='${datarootdir}' | ||||
| sysconfdir='${prefix}/etc' | ||||
| sharedstatedir='${prefix}/com' | ||||
| localstatedir='${prefix}/var' | ||||
| runstatedir='${localstatedir}/run' | ||||
| includedir='${prefix}/include' | ||||
| oldincludedir='/usr/include' | ||||
| docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' | ||||
| @ -1125,15 +1127,6 @@ do | ||||
|   | -silent | --silent | --silen | --sile | --sil) | ||||
|     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) | ||||
|     ac_prev=sbindir ;; | ||||
|   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | ||||
| @ -1271,7 +1264,7 @@ fi | ||||
| for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \ | ||||
| 		datadir sysconfdir sharedstatedir localstatedir includedir \ | ||||
| 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ | ||||
| 		libdir localedir mandir runstatedir | ||||
| 		libdir localedir mandir | ||||
| do | ||||
|   eval ac_val=\$$ac_var | ||||
|   # Remove trailing slashes. | ||||
| @ -1424,7 +1417,6 @@ Fine tuning of the installation directories: | ||||
|   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc] | ||||
|   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com] | ||||
|   --localstatedir=DIR     modifiable single-machine data [PREFIX/var] | ||||
|   --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run] | ||||
|   --libdir=DIR            object code libraries [EPREFIX/lib] | ||||
|   --includedir=DIR        C header files [PREFIX/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 | ||||
|                           library(default. no) | ||||
|   --enable-libltdl        use libltdl(default. no) | ||||
|   --enable-libunwind      use libunwind(default. no) | ||||
|   --enable-hclex          build libhclex(default. no) | ||||
|  | ||||
| Optional Packages: | ||||
| @ -18246,6 +18239,18 @@ fi | ||||
|  | ||||
| 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" | ||||
|  | ||||
|  | ||||
| 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_n "checking for main in -lunicows... " >&6; } | ||||
| if ${ac_cv_lib_unicows_main+:} false; then : | ||||
| @ -21148,6 +21204,34 @@ else | ||||
| 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. | ||||
| if test "${enable_hclex+set}" = set; then : | ||||
|   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. | ||||
| Usually this means the macro was only invoked conditionally." "$LINENO" 5 | ||||
| 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 | ||||
|   as_fn_error $? "conditional \"ENABLE_HCLEX\" was never defined. | ||||
| Usually this means the macro was only invoked conditionally." "$LINENO" 5 | ||||
|  | ||||
| @ -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([dlfcn.h ltdl.h sys/mman.h sys/uio.h]) | ||||
| AC_CHECK_HEADERS([sys/devpoll.h sys/epoll.h poll.h]) | ||||
| AC_CHECK_HEADERS([libunwind.h]) | ||||
|  | ||||
| dnl check data types | ||||
| dnl AC_CHECK_TYPE([wchar_t],  | ||||
| @ -161,6 +162,17 @@ AC_SEARCH_LIBS([lt_dlopen], [ltdl], [ | ||||
| LIBS="$save_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 this check doesn't look for a particular symbol | ||||
| dnl but for the symbol 'main' since i want to check  | ||||
| @ -643,6 +655,23 @@ then | ||||
| fi | ||||
| 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 ===== | ||||
| AC_ARG_ENABLE([hclex], | ||||
| 	[AS_HELP_STRING([--enable-hclex],[build libhclex(default. no)])], | ||||
|  | ||||
| @ -28,6 +28,9 @@ else | ||||
| LIBADD_LIB_COMMON += $(DL_LIBS) | ||||
| endif | ||||
|  | ||||
| if ENABLE_LIBUNWIND | ||||
| LIBADD_LIB_COMMON += $(UNWIND_LIBS) | ||||
| endif | ||||
|  | ||||
| pkgincludedir = $(includedir) | ||||
| pkglibdir = $(libdir) | ||||
|  | ||||
| @ -90,15 +90,16 @@ build_triplet = @build@ | ||||
| host_triplet = @host@ | ||||
| @ENABLE_LIBLTDL_TRUE@am__append_1 = $(LTDL_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@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-str.la | ||||
| bin_PROGRAMS = hcl$(EXEEXT) $(am__EXEEXT_1) | ||||
| @ENABLE_HCLEX_TRUE@am__append_5 = 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 = hcls hclc hclj | ||||
| @ENABLE_HCLEX_TRUE@am__append_6 = libhclex.la | ||||
| @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_8 = hcls hclc hclj | ||||
| subdir = lib | ||||
| ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 | ||||
| am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \ | ||||
| @ -148,8 +149,9 @@ LTLIBRARIES = $(pkglib_LTLIBRARIES) | ||||
| am__DEPENDENCIES_1 = | ||||
| @ENABLE_LIBLTDL_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) | ||||
| @ENABLE_LIBLTDL_FALSE@am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1) | ||||
| am__DEPENDENCIES_4 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \ | ||||
| 	$(am__DEPENDENCIES_3) | ||||
| @ENABLE_LIBUNWIND_TRUE@am__DEPENDENCIES_4 = $(am__DEPENDENCIES_1) | ||||
| 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 \ | ||||
| 	libhcl_la-debug.lo libhcl_la-decode.lo libhcl_la-dic.lo \ | ||||
| 	libhcl_la-err.lo libhcl_la-exec.lo libhcl_la-gc.lo \ | ||||
| @ -370,6 +372,7 @@ SET_MAKE = @SET_MAKE@ | ||||
| SHELL = @SHELL@ | ||||
| STRIP = @STRIP@ | ||||
| UNICOWS_LIBS = @UNICOWS_LIBS@ | ||||
| UNWIND_LIBS = @UNWIND_LIBS@ | ||||
| VERSION = @VERSION@ | ||||
| abs_builddir = @abs_builddir@ | ||||
| abs_srcdir = @abs_srcdir@ | ||||
| @ -417,7 +420,6 @@ pdfdir = @pdfdir@ | ||||
| prefix = @prefix@ | ||||
| program_transform_name = @program_transform_name@ | ||||
| psdir = @psdir@ | ||||
| runstatedir = @runstatedir@ | ||||
| sbindir = @sbindir@ | ||||
| sharedstatedir = @sharedstatedir@ | ||||
| srcdir = @srcdir@ | ||||
| @ -441,10 +443,11 @@ CPPFLAGS_ALL_COMMON = \ | ||||
| ################################################## | ||||
| CPPFLAGS_LIB_COMMON = $(CPPFLAGS_ALL_COMMON) | ||||
| 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 \ | ||||
| 	$(am__append_6) | ||||
| pkglib_LTLIBRARIES = libhcl.la $(am__append_5) | ||||
| 	$(am__append_7) | ||||
| pkglib_LTLIBRARIES = libhcl.la $(am__append_6) | ||||
| libhcl_la_SOURCES = \ | ||||
| 	hcl.h \ | ||||
| 	hcl-cmn.h \ | ||||
| @ -478,8 +481,8 @@ libhcl_la_SOURCES = \ | ||||
|  | ||||
| libhcl_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON) | ||||
| libhcl_la_LDFLAGS = $(LDFLAGS_LIB_COMMON) | ||||
| libhcl_la_LIBADD = $(LIBADD_LIB_COMMON) $(am__append_3) | ||||
| libhcl_la_DEPENDENCIES = $(am__append_4) | ||||
| libhcl_la_LIBADD = $(LIBADD_LIB_COMMON) $(am__append_4) | ||||
| libhcl_la_DEPENDENCIES = $(am__append_5) | ||||
| hcl_SOURCES = main.c  | ||||
| hcl_CPPFLAGS = $(CPPFLAGS_LIB_COMMON) | ||||
| hcl_LDFLAGS = $(LDFLAGS_LIB_COMMON) | ||||
|  | ||||
| @ -26,6 +26,10 @@ | ||||
|  | ||||
| #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_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'}; | ||||
| @ -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 | ||||
|  * -------------------------------------------------------------------------- */ | ||||
|  | ||||
| void hcl_assertfailed (hcl_t* hcl, const hcl_bch_t* expr, const hcl_bch_t* file, hcl_oow_t line) | ||||
| #if defined(HCL_ENABLE_LIBUNWIND) | ||||
| 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]; | ||||
| 	hcl_oow_t btsize; | ||||
| 	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)); | ||||
| 	btsyms = backtrace_symbols (btarray, btsize); | ||||
| 	if (btsyms) | ||||
| @ -501,8 +528,22 @@ void hcl_assertfailed (hcl_t* hcl, const hcl_bch_t* expr, const hcl_bch_t* file, | ||||
| 		} | ||||
| 		free (btsyms); | ||||
| 	} | ||||
| } | ||||
| #else | ||||
| static void backtrace_stack_frames (hcl_t* hcl) | ||||
| { | ||||
| 	/* do nothing. not supported */ | ||||
| } | ||||
| #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) | ||||
| 	ExitProcess (249); | ||||
|  | ||||
| @ -81,6 +81,9 @@ | ||||
| /* Define to 1 if you have the `isatty' function. */ | ||||
| #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. */ | ||||
| #undef HAVE_LOG10Q | ||||
|  | ||||
| @ -213,6 +216,9 @@ | ||||
| /* Define to 1 if you have the <unistd.h> header file. */ | ||||
| #undef HAVE_UNISTD_H | ||||
|  | ||||
| /* libunwind is available */ | ||||
| #undef HAVE_UNWIND_LIB | ||||
|  | ||||
| /* Define to 1 if you have the `usleep' function. */ | ||||
| #undef HAVE_USLEEP | ||||
|  | ||||
| @ -264,6 +270,9 @@ | ||||
| /* use libltdl when loading a dynamic module */ | ||||
| #undef HCL_ENABLE_LIBLTDL | ||||
|  | ||||
| /* use libunwind for backtracing stack frames */ | ||||
| #undef HCL_ENABLE_LIBUNWIND | ||||
|  | ||||
| /* link modules statically into the main library */ | ||||
| #undef HCL_ENABLE_STATIC_MODULE | ||||
|  | ||||
|  | ||||
| @ -329,6 +329,7 @@ SET_MAKE = @SET_MAKE@ | ||||
| SHELL = @SHELL@ | ||||
| STRIP = @STRIP@ | ||||
| UNICOWS_LIBS = @UNICOWS_LIBS@ | ||||
| UNWIND_LIBS = @UNWIND_LIBS@ | ||||
| VERSION = @VERSION@ | ||||
| abs_builddir = @abs_builddir@ | ||||
| abs_srcdir = @abs_srcdir@ | ||||
| @ -376,7 +377,6 @@ pdfdir = @pdfdir@ | ||||
| prefix = @prefix@ | ||||
| program_transform_name = @program_transform_name@ | ||||
| psdir = @psdir@ | ||||
| runstatedir = @runstatedir@ | ||||
| sbindir = @sbindir@ | ||||
| sharedstatedir = @sharedstatedir@ | ||||
| srcdir = @srcdir@ | ||||
|  | ||||
		Reference in New Issue
	
	Block a user