Merge pull request #1363 from facebook/backtrace
backtrace support compiled with more conditions
This commit is contained in:
+7
-4
@@ -134,10 +134,13 @@ 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
|
||||||
ALL_SYMBOLS := 0
|
ifeq ($(BACKTRACE), 0)
|
||||||
|
DEBUGFLAGS += -DBACKTRACE_ENABLE=0
|
||||||
|
endif
|
||||||
ifeq (,$(filter Windows%, $(OS)))
|
ifeq (,$(filter Windows%, $(OS)))
|
||||||
ifeq ($(ALL_SYMBOLS), 1)
|
ifeq ($(BACKTRACE), 1)
|
||||||
|
DEBUGFLAGS += -DBACKTRACE_ENABLE=1
|
||||||
DEBUGFLAGS_LD += -rdynamic
|
DEBUGFLAGS_LD += -rdynamic
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@@ -168,7 +171,7 @@ endif
|
|||||||
$(CC) $(FLAGS) $^ $(RES_FILE) -o $@$(EXT) $(LDFLAGS)
|
$(CC) $(FLAGS) $^ $(RES_FILE) -o $@$(EXT) $(LDFLAGS)
|
||||||
|
|
||||||
.PHONY: zstd-release
|
.PHONY: zstd-release
|
||||||
zstd-release: DEBUGFLAGS :=
|
zstd-release: DEBUGFLAGS := -DBACKTRACE_ENABLE=0
|
||||||
zstd-release: DEBUGFLAGS_LD :=
|
zstd-release: DEBUGFLAGS_LD :=
|
||||||
zstd-release: zstd
|
zstd-release: zstd
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -61,12 +61,12 @@ There are however other Makefile targets that create different variations of CLI
|
|||||||
In which case, linking stage will fail if `lz4` library cannot be found.
|
In which case, linking stage will fail if `lz4` library cannot be found.
|
||||||
This is useful to prevent silent feature disabling.
|
This is useful to prevent silent feature disabling.
|
||||||
|
|
||||||
- __ALL_SYMBOLS__ : `zstd` can display a stack backtrace if the execution
|
- __BACKTRACE__ : `zstd` can display a stack backtrace when execution
|
||||||
generates a runtime exception. By default, this feature may be
|
generates a runtime exception. By default, this feature may be
|
||||||
degraded/disabled on some platforms unless additional compiler directives are
|
degraded/disabled on some platforms unless additional compiler directives are
|
||||||
applied. When triaging a runtime issue, enabling this feature can provided
|
applied. When triaging a runtime issue, enabling this feature can provide
|
||||||
more context to determine the location of the fault.
|
more context to determine the location of the fault.
|
||||||
Example : `make zstd ALL_SYMBOLS=1`
|
Example : `make zstd BACKTRACE=1`
|
||||||
|
|
||||||
|
|
||||||
#### Aggregation of parameters
|
#### Aggregation of parameters
|
||||||
|
|||||||
+25
-11
@@ -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(BACKTRACES_ENABLE) && \
|
|
||||||
(defined(__GLIBC__) || (defined(__APPLE__) && defined(__MACH__)) )
|
|
||||||
# define BACKTRACES_ENABLE 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*-*************************************
|
/*-*************************************
|
||||||
* Includes
|
* Includes
|
||||||
***************************************/
|
***************************************/
|
||||||
@@ -37,9 +31,6 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h> /* errno */
|
#include <errno.h> /* errno */
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#ifdef BACKTRACES_ENABLE
|
|
||||||
# include <execinfo.h> /* backtrace, backtrace_symbols */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (_MSC_VER)
|
#if defined (_MSC_VER)
|
||||||
# include <sys/stat.h>
|
# include <sys/stat.h>
|
||||||
@@ -167,7 +158,30 @@ static void clearHandler(void)
|
|||||||
/*-*********************************************************
|
/*-*********************************************************
|
||||||
* Termination signal trapping (Print debug stack trace)
|
* Termination signal trapping (Print debug stack trace)
|
||||||
***********************************************************/
|
***********************************************************/
|
||||||
#ifdef BACKTRACES_ENABLE
|
#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)
|
||||||
|
/* automatic detector : backtrace enabled by default on linux+glibc and osx */
|
||||||
|
# if (defined(__linux__) && defined(__GLIBC__)) \
|
||||||
|
|| (defined(__APPLE__) && defined(__MACH__))
|
||||||
|
# define BACKTRACE_ENABLE 1
|
||||||
|
# else
|
||||||
|
# define BACKTRACE_ENABLE 0
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* note : after this point, BACKTRACE_ENABLE is necessarily defined */
|
||||||
|
|
||||||
|
|
||||||
|
#if BACKTRACE_ENABLE
|
||||||
|
|
||||||
|
#include <execinfo.h> /* backtrace, backtrace_symbols */
|
||||||
|
|
||||||
#define MAX_STACK_FRAMES 50
|
#define MAX_STACK_FRAMES 50
|
||||||
|
|
||||||
@@ -208,7 +222,7 @@ static void ABRThandler(int sig) {
|
|||||||
|
|
||||||
void FIO_addAbortHandler()
|
void FIO_addAbortHandler()
|
||||||
{
|
{
|
||||||
#ifdef BACKTRACES_ENABLE
|
#if BACKTRACE_ENABLE
|
||||||
signal(SIGABRT, ABRThandler);
|
signal(SIGABRT, ABRThandler);
|
||||||
signal(SIGFPE, ABRThandler);
|
signal(SIGFPE, ABRThandler);
|
||||||
signal(SIGILL, ABRThandler);
|
signal(SIGILL, ABRThandler);
|
||||||
|
|||||||
Reference in New Issue
Block a user