0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 09:41:54 +00:00

Debug: Do not compile allocator debug journals in unless requested.

These journals can become very memory-heavy when it comes to
constrained environments where every 100k of RAM matters.
This commit is contained in:
Maria Matejka 2024-10-01 15:30:00 +02:00
parent 5400add300
commit 0eb1548cc4
3 changed files with 16 additions and 2 deletions

View File

@ -30,6 +30,12 @@ AC_ARG_ENABLE([debug-expensive],
[enable_debug_expensive=no] [enable_debug_expensive=no]
) )
AC_ARG_ENABLE([debug-allocator],
[AS_HELP_STRING([--enable-debug-allocator], [enable internal memory allocator journal (implies --enable-debug) @<:@no@:>@])],
[],
[enable_debug_expensive=no]
)
AC_ARG_ENABLE([memcheck], AC_ARG_ENABLE([memcheck],
[AS_HELP_STRING([--enable-memcheck], [check memory allocations when debugging @<:@yes@:>@])], [AS_HELP_STRING([--enable-memcheck], [check memory allocations when debugging @<:@yes@:>@])],
[], [],
@ -78,6 +84,10 @@ AC_ARG_VAR([FLEX], [location of the Flex program])
AC_ARG_VAR([BISON], [location of the Bison program]) AC_ARG_VAR([BISON], [location of the Bison program])
AC_ARG_VAR([M4], [location of the M4 program]) AC_ARG_VAR([M4], [location of the M4 program])
if test "$enable_debug_allocator" = yes; then
enable_debug=yes
fi
if test "$enable_debug_expensive" = yes; then if test "$enable_debug_expensive" = yes; then
enable_debug=yes enable_debug=yes
fi fi
@ -445,6 +455,10 @@ if test "$enable_debug" = yes ; then
if test "$enable_debug_expensive" = yes ; then if test "$enable_debug_expensive" = yes ; then
AC_DEFINE([ENABLE_EXPENSIVE_CHECKS], [1], [Define to 1 if you want to run expensive consistency checks.]) AC_DEFINE([ENABLE_EXPENSIVE_CHECKS], [1], [Define to 1 if you want to run expensive consistency checks.])
fi fi
if test "$enable_debug_allocator" = yes; then
AC_DEFINE([DEBUG_ALLOCATOR], [1], [Define to 1 if you want to store journals from memory allocations.])
fi
fi fi
if test "$enable_compact_tries" = yes ; then if test "$enable_compact_tries" = yes ; then

View File

@ -14,7 +14,7 @@
#ifndef HAVE_LIBDMALLOC #ifndef HAVE_LIBDMALLOC
#if DEBUGGING #if DEBUG_ALLOCATOR
struct minfo { struct minfo {
void *ptr; void *ptr;
uint size; uint size;

View File

@ -52,7 +52,7 @@ alloc_preconfig(struct alloc_config *ac)
# define PROTECT_PAGE(pg) # define PROTECT_PAGE(pg)
# define UNPROTECT_PAGE(pg) # define UNPROTECT_PAGE(pg)
# if DEBUGGING # if DEBUG_ALLOCATOR
# ifdef ENABLE_EXPENSIVE_CHECKS # ifdef ENABLE_EXPENSIVE_CHECKS
# undef PROTECT_PAGE # undef PROTECT_PAGE
# undef UNPROTECT_PAGE # undef UNPROTECT_PAGE