Merge branch 'backtrace' of github.com:facebook/zstd into backtrace

This commit is contained in:
Julian Fessard 2018-10-09 17:24:48 -07:00
commit 0ea286f740
2 changed files with 21 additions and 20 deletions

View File

@ -134,8 +134,10 @@ else
LZ4_MSG := $(NO_LZ4_MSG) LZ4_MSG := $(NO_LZ4_MSG)
endif endif
# enable backtrace symbol names for Linux & Darwin # explicit backtrace enable/disable for Linux & Darwin
BACKTRACE ?= 0 ifeq ($(BACKTRACE), 0)
DEBUGFLAGS += -DBACKTRACE_ENABLE=0
endif
ifeq (,$(filter Windows%, $(OS))) ifeq (,$(filter Windows%, $(OS)))
ifeq ($(BACKTRACE), 1) ifeq ($(BACKTRACE), 1)
DEBUGFLAGS += -DBACKTRACE_ENABLE=1 DEBUGFLAGS += -DBACKTRACE_ENABLE=1

View File

@ -20,21 +20,6 @@
# define _POSIX_SOURCE 1 /* disable %llu warnings with MinGW on Windows */ # define _POSIX_SOURCE 1 /* disable %llu warnings with MinGW on Windows */
#endif #endif
#if defined(__has_feature) && !defined(BACKTRACE_ENABLE) /* Clang compiler */
# if (__has_feature(address_sanitizer))
# define BACKTRACE_ENABLE 0
# endif /* __has_feature(address_sanitizer) */
#elif defined(__SANITIZE_ADDRESS__) && !defined(BACKTRACE_ENABLE) /* GCC compiler */
# define BACKTRACE_ENABLE 0
#endif
#if !defined(BACKTRACE_ENABLE) \
&& ((defined(__linux__) && defined(__GLIBC__)) \
|| (defined(__APPLE__) && defined(__MACH__)) )
# define BACKTRACE_ENABLE 1
#endif
/*-************************************* /*-*************************************
* Includes * Includes
***************************************/ ***************************************/
@ -46,9 +31,6 @@
#include <assert.h> #include <assert.h>
#include <errno.h> /* errno */ #include <errno.h> /* errno */
#include <signal.h> #include <signal.h>
#if defined(BACKTRACE_ENABLE) && (BACKTRACE_ENABLE >= 1)
# include <execinfo.h> /* backtrace, backtrace_symbols */
#endif
#if defined (_MSC_VER) #if defined (_MSC_VER)
# include <sys/stat.h> # include <sys/stat.h>
@ -176,8 +158,25 @@ static void clearHandler(void)
/*-********************************************************* /*-*********************************************************
* Termination signal trapping (Print debug stack trace) * Termination signal trapping (Print debug stack trace)
***********************************************************/ ***********************************************************/
#if defined(__has_feature) && !defined(BACKTRACE_ENABLE) /* Clang compiler */
# if (__has_feature(address_sanitizer))
# define BACKTRACE_ENABLE 0
# endif /* __has_feature(address_sanitizer) */
#elif defined(__SANITIZE_ADDRESS__) && !defined(BACKTRACE_ENABLE) /* GCC compiler */
# define BACKTRACE_ENABLE 0
#endif
#if !defined(BACKTRACE_ENABLE) \
&& ((defined(__linux__) && defined(__GLIBC__)) \
|| (defined(__APPLE__) && defined(__MACH__)) )
# define BACKTRACE_ENABLE 1
#endif
#if defined(BACKTRACE_ENABLE) && (BACKTRACE_ENABLE>=1) #if defined(BACKTRACE_ENABLE) && (BACKTRACE_ENABLE>=1)
#include <execinfo.h> /* backtrace, backtrace_symbols */
#define MAX_STACK_FRAMES 50 #define MAX_STACK_FRAMES 50
static void ABRThandler(int sig) { static void ABRThandler(int sig) {