Browse Source

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

personal/stbuehler/wip
Thomas Porzelt 12 years ago
parent
commit
f285ad372e
  1. 1
      configure.ac
  2. 1
      src/CMakeLists.txt
  3. 8
      src/main/profiler.c
  4. 1
      wscript

1
configure.ac

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

1
src/CMakeLists.txt

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

8
src/main/profiler.c

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

1
wscript

@ -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':

Loading…
Cancel
Save