diff --git a/programs/Makefile b/programs/Makefile index 49319484c..5c1ac33eb 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -47,8 +47,8 @@ DEBUGFLAGS+=-Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \ -Wstrict-prototypes -Wundef -Wpointer-arith -Wformat-security \ -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \ -Wredundant-decls +DEBUGFLAGS_LD+=-rdynamic CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS) -LDFLAGS += -rdynamic FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) @@ -145,7 +145,7 @@ allVariants: zstd zstd-compress zstd-decompress zstd-small zstd-nolegacy $(ZSTDDECOMP_O): CFLAGS += $(ALIGN_LOOP) zstd : CPPFLAGS += $(THREAD_CPP) $(ZLIBCPP) $(LZMACPP) $(LZ4CPP) -zstd : LDFLAGS += $(THREAD_LD) $(ZLIBLD) $(LZMALD) $(LZ4LD) +zstd : LDFLAGS += $(THREAD_LD) $(ZLIBLD) $(LZMALD) $(LZ4LD) $(DEBUGFLAGS_LD) zstd : CPPFLAGS += -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT) zstd : $(ZSTDLIB_FILES) zstdcli.o fileio.o bench.o datagen.o dibio.o @echo "$(THREAD_MSG)" @@ -159,6 +159,7 @@ endif .PHONY: zstd-release zstd-release: DEBUGFLAGS := +zstd-release: DEBUGFLAGS_LD := zstd-release: zstd zstd32 : CPPFLAGS += $(THREAD_CPP) diff --git a/programs/fileio.c b/programs/fileio.c index 678143d9d..5f6b12e51 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -166,37 +166,37 @@ static void clearHandler(void) #ifndef _WIN32 static void ABRThandler(int sig) { - const char* name; - void* addrlist[MAX_STACK_FRAMES + 1]; - char** symbollist; - U32 addrlen, i; + const char* name; + void* addrlist[MAX_STACK_FRAMES]; + char** symbollist; + U32 addrlen, i; - switch (sig) { - case SIGABRT: name = "SIGABRT"; break; - case SIGFPE: name = "SIGFPE"; break; - case SIGILL: name = "SIGILL"; break; - case SIGINT: name = "SIGINT"; break; - case SIGSEGV: name = "SIGSEGV"; break; - default: name = "UNKNOWN"; - } + switch (sig) { + case SIGABRT: name = "SIGABRT"; break; + case SIGFPE: name = "SIGFPE"; break; + case SIGILL: name = "SIGILL"; break; + case SIGINT: name = "SIGINT"; break; + case SIGSEGV: name = "SIGSEGV"; break; + default: name = "UNKNOWN"; + } - DISPLAY("Caught %s signal, printing stack:\n", name); - // Retrieve current stack addresses. - addrlen = backtrace(addrlist, sizeof(addrlist) / sizeof(void*)); - if (addrlen == 0) { - DISPLAY("\n"); - return; - } - // Create readable strings to each frame. - symbollist = backtrace_symbols(addrlist, addrlen); - // Print the stack trace, excluding calls handling the signal. - for (i = ZSTD_START_SYMBOLLIST_FRAME; i < addrlen; i++) { - DISPLAY("%s\n", symbollist[i]); - } - free(symbollist); - // Reset and raise the signal so default handler runs. - signal(sig, SIG_DFL); - raise(sig); + DISPLAY("Caught %s signal, printing stack:\n", name); + /* Retrieve current stack addresses. */ + addrlen = backtrace(addrlist, MAX_STACK_FRAMES); + if (addrlen == 0) { + DISPLAY("\n"); + return; + } + /* Create readable strings to each frame. */ + symbollist = backtrace_symbols(addrlist, addrlen); + /* Print the stack trace, excluding calls handling the signal. */ + for (i = ZSTD_START_SYMBOLLIST_FRAME; i < addrlen; i++) { + DISPLAY("%s\n", symbollist[i]); + } + free(symbollist); + /* Reset and raise the signal so default handler runs. */ + signal(sig, SIG_DFL); + raise(sig); } #endif