fixed explicit BACKTRACE order

and automatic linux backtrace detection :
__GLIBC__ must be tested after #include <features.h>
dev
Yann Collet 2018-10-09 17:12:21 -07:00
parent 1e0c5466c5
commit e0ab6b61b7
2 changed files with 13 additions and 11 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,12 +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(BACKTRACE_ENABLE) \
&& ((defined(__linux__) && defined(__GLIBC__)) \
|| (defined(__APPLE__) && defined(__MACH__)) )
# define BACKTRACE_ENABLE 1
#endif
/*-************************************* /*-*************************************
* Includes * Includes
@ -38,9 +32,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>
@ -168,8 +159,17 @@ static void clearHandler(void)
/*-********************************************************* /*-*********************************************************
* Termination signal trapping (Print debug stack trace) * Termination signal trapping (Print debug stack trace)
***********************************************************/ ***********************************************************/
#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) {