mirror of
https://github.com/MariaDB/server.git
synced 2025-02-02 03:51:50 +01:00
Merge the backtrace onto the mainline. Refs #2387. [t:2387].
{{{ svn merge -r 18063:18082 https://svn.tokutek.com/tokudb/toku/tokudb.2387 }}} git-svn-id: file:///svn/toku/tokudb@18084 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
parent
3d46ee3fd4
commit
f62b35b745
5 changed files with 73 additions and 32 deletions
1
Makefile
1
Makefile
|
@ -81,4 +81,3 @@ check-coverage-range-tree-tests:
|
|||
(cd src/range_tree/tests && $(MAKE) clean && $(MAKE) -k check.lin VGRIND="" OPTFLAGS=-O0 GCOV_FLAGS="-fprofile-arcs -ftest-coverage")
|
||||
check-coverage-lock-tree-tests:
|
||||
(cd src/lock_tree/tests && $(MAKE) clean && $(MAKE) -k check.lin VGRIND="" OPTFLAGS=-O0 GCOV_FLAGS="-fprofile-arcs -ftest-coverage")
|
||||
|
||||
|
|
|
@ -2,11 +2,14 @@
|
|||
CPPFLAGS = -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
|
||||
CPPFLAGS += -I../../toku_include -I.. -I.
|
||||
CFLAGS = -Wall -Werror -g -O0 -std=c99
|
||||
ifeq ($(GCCVERSION),4.4.2)
|
||||
CFLAGS += -Wno-deprecated
|
||||
endif
|
||||
ifneq ($(GCOV),)
|
||||
CFLAGS += -fprofile-arcs -ftest-coverage -DGCOV
|
||||
endif
|
||||
LDFLAGS = ../libtokuportability.a -lpthread
|
||||
SRCS = $(wildcard test-*.c)
|
||||
SRCS = $(wildcard *.c)
|
||||
TARGETS = $(patsubst %.c,%,$(SRCS))
|
||||
RUNTARGETS = $(patsubst %,%.tdbrun,$(TARGETS))
|
||||
VGRIND = valgrind
|
||||
|
@ -19,10 +22,10 @@ HERE=linux/tests
|
|||
ifeq ($(SUMMARIZE),1)
|
||||
SUMMARIZE_CMD = ;if test $$? = 0; then printf "%-60sPASS\n" $(HERE)/$@; else printf "%-60sFAIL\n" $(HERE)/$@ ; test 0 = 1; fi
|
||||
SUMMARIZE_SHOULD_FAIL= ;if test $$? = 0; then printf "%-60sXFAIL\n" $(HERE)/$@; else printf "%-60sXPASS\n" $(HERE)/$@ ; test 0 = 1; fi
|
||||
INVERTER=;test $$? -ne 0
|
||||
else
|
||||
SUMMARIZE_CMD =
|
||||
endif
|
||||
INVERTER=;test $$? -ne 0
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
|
@ -50,6 +53,30 @@ else
|
|||
$(SUMMARIZE_CMD)
|
||||
endif
|
||||
|
||||
# check to see if that logic makes an error when there is a leak.
|
||||
try-leak.tdbrun: try-leak
|
||||
ifeq ($(VGRIND),)
|
||||
./$< $(SUMMARIZE_CMD)
|
||||
else
|
||||
$(VGRIND) --error-exitcode=1 --quiet --leak-check=full --log-file=$<.check.valgrind ./$< >$<.check.output 2>&1; \
|
||||
if [ $$? = 0 ] ; then \
|
||||
lines=`cat $<.check.valgrind | wc -l`; \
|
||||
if [ $$lines -ne 0 ] ; then cat $<.check.valgrind; test 0 = 1; fi \
|
||||
else \
|
||||
test 0 = 1; \
|
||||
fi \
|
||||
$(INVERTER) \
|
||||
$(SUMMARIZE_CMD)
|
||||
endif
|
||||
|
||||
try-assert0.tdbrun: try-assert0
|
||||
./$< 2> /dev/null $(INVERTER) $(SUMMARIZE_CMD)
|
||||
|
||||
clean:
|
||||
rm -rf $(TARGETS) *.check.output *.check.valgrind pwrite4g.data testdir
|
||||
|
||||
try-assert0.tdbrun:
|
||||
|
||||
|
||||
foo:
|
||||
echo $(TARGETS)
|
||||
|
|
|
@ -59,6 +59,9 @@
|
|||
toku_os_get_max_process_data_size;
|
||||
toku_os_get_phys_memory_size;
|
||||
|
||||
toku_do_assert;
|
||||
toku_do_assert_fail;
|
||||
|
||||
local: *;
|
||||
};
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
#error NDEBUG should not be set
|
||||
#endif
|
||||
|
||||
void toku_do_assert(int,const char*/*expr_as_string*/,const char */*fun*/,const char*/*file*/,int/*line*/);
|
||||
void toku_do_assert_fail(const char*/*expr_as_string*/,const char */*fun*/,const char*/*file*/,int/*line*/) __attribute__((__visibility__("default"))) __attribute__((__noreturn__));
|
||||
void toku_do_assert(int,const char*/*expr_as_string*/,const char */*fun*/,const char*/*file*/,int/*line*/) __attribute__((__visibility__("default")));
|
||||
|
||||
// Define GCOV if you want to get test-coverage information that ignores the assert statements.
|
||||
// #define GCOV
|
||||
|
@ -16,7 +17,7 @@ void toku_do_assert(int,const char*/*expr_as_string*/,const char */*fun*/,const
|
|||
#if defined(GCOV) || TOKU_WINDOWS
|
||||
#define assert(expr) toku_do_assert((expr) != 0, #expr, __FUNCTION__, __FILE__, __LINE__)
|
||||
#else
|
||||
#include <assert.h>
|
||||
#define assert(expr) ((expr) ? (void)0 : toku_do_assert_fail(#expr, __FUNCTION__, __FILE__, __LINE__))
|
||||
#endif
|
||||
|
||||
#ifdef GCOV
|
||||
|
|
|
@ -4,39 +4,50 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#if !TOKU_WINDOWS
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
|
||||
int toku_continue_on_assert_failure=0;
|
||||
|
||||
static void toku_assert_failed_but_continue_anyway (void) __attribute__((noinline));
|
||||
#if !TOKU_WINDOWS
|
||||
#define N_POINTERS 1000
|
||||
// These are statically allocated so that the backtrace can run without any calls to malloc()
|
||||
static void *backtrace_pointers[N_POINTERS];
|
||||
#endif
|
||||
|
||||
static void
|
||||
toku_assert_failed_but_continue_anyway (void) {
|
||||
printf("Assertion failed, but continuing anyway\n");
|
||||
void toku_do_assert_fail (const char* expr_as_string,const char *function,const char*file,int line)
|
||||
{
|
||||
fprintf(stderr, "%s:%d %s: Assertion `%s' failed\n", file,line,function,expr_as_string);
|
||||
|
||||
// backtrace
|
||||
#if !TOKU_WINDOWS
|
||||
int n = backtrace(backtrace_pointers, N_POINTERS);
|
||||
fprintf(stderr, "Backtrace: (Note: toku_do_assert=0x%p)\n", toku_do_assert); fflush(stderr);
|
||||
backtrace_symbols_fd(backtrace_pointers, n, fileno(stderr));
|
||||
#endif
|
||||
|
||||
fflush(stderr);
|
||||
|
||||
#if TOKU_WINDOWS
|
||||
//Following commented methods will not always end the process (could hang).
|
||||
//They could be unacceptable for other reasons as well (popups,
|
||||
//flush buffers before quitting, etc)
|
||||
// abort()
|
||||
// assert(FALSE) (assert.h assert)
|
||||
// raise(SIGABRT)
|
||||
// divide by 0
|
||||
// null dereference
|
||||
// _exit
|
||||
// exit
|
||||
// ExitProcess
|
||||
TerminateProcess(GetCurrentProcess(), 134); //Only way found so far to unconditionally
|
||||
//Terminate the process
|
||||
#endif
|
||||
abort();
|
||||
}
|
||||
|
||||
void toku_do_assert(int expr,const char* expr_as_string,const char *function,const char*file,int line) {
|
||||
if (expr==0) {
|
||||
fprintf(stderr, "%s:%d %s: Assertion `%s' failed\n", file,line,function,expr_as_string);
|
||||
if (!toku_continue_on_assert_failure) {
|
||||
fflush(stderr);
|
||||
#if TOKU_WINDOWS
|
||||
//Following commented methods will not always end the process (could hang).
|
||||
//They could be unacceptable for other reasons as well (popups,
|
||||
//flush buffers before quitting, etc)
|
||||
// abort()
|
||||
// assert(FALSE) (assert.h assert)
|
||||
// raise(SIGABRT)
|
||||
// divide by 0
|
||||
// null dereference
|
||||
// _exit
|
||||
// exit
|
||||
// ExitProcess
|
||||
TerminateProcess(GetCurrentProcess(), 134); //Only way found so far to unconditionally
|
||||
//Terminate the process
|
||||
#endif
|
||||
abort();
|
||||
}
|
||||
else
|
||||
toku_assert_failed_but_continue_anyway();
|
||||
toku_do_assert_fail(expr_as_string, function, file, line);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue