[core,waf,autoconf,cmake] Add check for execinfo.h and disable stacktraces in profiler if not available
This commit is contained in:
parent
fa1c73cbe6
commit
f285ad372e
|
@ -35,6 +35,7 @@ AC_CHECK_HEADERS([ \
|
|||
sys/types.h \
|
||||
sys/uio.h \
|
||||
sys/un.h \
|
||||
execinfo.h \
|
||||
])
|
||||
|
||||
# pkglibdir
|
||||
|
|
|
@ -43,6 +43,7 @@ CHECK_INCLUDE_FILES(sys/types.h HAVE_SYS_TYPES_H)
|
|||
CHECK_INCLUDE_FILES(sys/uio.h HAVE_SYS_UIO_H)
|
||||
CHECK_INCLUDE_FILES(sys/un.h HAVE_SYS_UN_H)
|
||||
CHECK_INCLUDE_FILES(unistd.h HAVE_UNISTD_H)
|
||||
CHECK_INCLUDE_FILES(execinfo.h HAVE_EXECINFO_H)
|
||||
|
||||
# will be needed for auth
|
||||
CHECK_INCLUDE_FILES(crypt.h HAVE_CRYPT_H)
|
||||
|
|
|
@ -9,7 +9,11 @@
|
|||
#include <lighttpd/base.h>
|
||||
#include <lighttpd/profiler.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef HAVE_EXECINFO_H
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
|
||||
#if defined(LIGHTY_OS_MACOSX)
|
||||
#include <malloc/malloc.h>
|
||||
#elif defined(LIGHTY_OS_LINUX)
|
||||
|
@ -75,7 +79,9 @@ static void profiler_hashtable_insert(gpointer addr, gsize size) {
|
|||
block = profiler_block_new();
|
||||
block->addr = addr;
|
||||
block->size = size;
|
||||
#ifdef HAVE_EXECINFO_H
|
||||
block->stackframes_num = backtrace(block->stackframes, 12);
|
||||
#endif
|
||||
|
||||
block->next = profiler_hashtable[hash % PROFILER_HASHTABLE_SIZE];
|
||||
profiler_hashtable[hash % PROFILER_HASHTABLE_SIZE] = block;
|
||||
|
@ -289,7 +295,9 @@ void li_profiler_dump() {
|
|||
leaked_size += block->size;
|
||||
len = sprintf(str, "--------------- unfreed block of %"G_GSIZE_FORMAT" bytes @ %p ---------------\n", block->size, block->addr);
|
||||
profiler_write(str, len);
|
||||
#ifdef HAVE_EXECINFO_H
|
||||
backtrace_symbols_fd(block->stackframes, block->stackframes_num, profiler_output_fd);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue