2
0
Fork 0

[core,waf,autoconf,cmake] Add check for execinfo.h and disable stacktraces in profiler if not available

This commit is contained in:
Thomas Porzelt 2010-05-09 14:18:52 +02:00
parent fa1c73cbe6
commit f285ad372e
4 changed files with 11 additions and 0 deletions

View File

@ -35,6 +35,7 @@ AC_CHECK_HEADERS([ \
sys/types.h \
sys/uio.h \
sys/un.h \
execinfo.h \
])
# pkglibdir

View File

@ -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)

View File

@ -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
}
}

View File

@ -154,6 +154,7 @@ def configure(conf):
conf.check(header_name='sys/resource.h')
conf.check(header_name='sys/sendfile.h')
conf.check(header_name='sys/un.h')
conf.check(header_name='execinfo.h')
# check for available functions
if sys.platform == 'linux2':