]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Expensive check declaration
authorMaria Matejka <mq@ucw.cz>
Wed, 14 Aug 2019 14:22:39 +0000 (16:22 +0200)
committerMaria Matejka <mq@ucw.cz>
Fri, 1 May 2020 13:19:12 +0000 (15:19 +0200)
Intended to be run at every operation with complex data structures
to check their consistency and validity.

configure.ac
lib/birdlib.h

index da8546a6934133d1a6f774c22bbe0e268c18a45d..96f666442d249f76e090e38a4ae08e63231512f2 100644 (file)
@@ -24,6 +24,12 @@ AC_ARG_ENABLE([debug-generated],
   [enable_debug_generated=no]
 )
 
+AC_ARG_ENABLE([debug-expensive],
+  [AS_HELP_STRING([--enable-debug-expensive], [enable expensive consistency checks (implies --enable-debug) @<:@no@:>@])],
+  [],
+  [enable_debug_expensive=no]
+)
+
 AC_ARG_ENABLE([memcheck],
   [AS_HELP_STRING([--enable-memcheck], [check memory allocations when debugging @<:@yes@:>@])],
   [],
@@ -72,6 +78,9 @@ AC_ARG_VAR([FLEX], [location of the Flex program])
 AC_ARG_VAR([BISON], [location of the Bison program])
 AC_ARG_VAR([M4], [location of the M4 program])
 
+if test "$enable_debug_expensive" = yes; then
+  enable_debug = yes
+fi
 
 if test "$srcdir" = . ; then
   # Building in current directory => create obj directory holding all objects
@@ -388,6 +397,10 @@ if test "$enable_debug" = yes ; then
       AC_CHECK_LIB([efence], [malloc])
     fi
   fi
+
+  if test "enable_debug_expensive" = yes ; then
+    AC_DEFINE([ENABLE_EXPENSIVE_CHECKS], [1], [Define to 1 if you want to run expensive consistency checks.])
+  fi
 fi
 
 CLIENT=birdcl
index caa26b9421b9b6819161aee366d68a79fc76a652..23036c1b1ea69cf4173936bb41faad89b8ea337a 100644 (file)
@@ -165,14 +165,21 @@ void debug(const char *msg, ...); /* Printf to debug output */
 
 #define ASSERT_DIE(x) do { if (!(x)) bug("Assertion '%s' failed at %s:%d", #x, __FILE__, __LINE__); } while(0)
 
+#define EXPENSIVE_CHECK(x) /* intentionally left blank */
+
 #ifdef DEBUGGING
 #define ASSERT(x) ASSERT_DIE(x)
 #define ASSUME(x) ASSERT_DIE(x)
+#ifdef ENABLE_EXPENSIVE_CHECKS
+#undef EXPENSIVE_CHECK
+#define EXPENSIVE_CHECK(x) ASSERT_DIE(x)
+#endif
 #else
 #define ASSERT(x) do { if (!(x)) log(L_BUG "Assertion '%s' failed at %s:%d", #x, __FILE__, __LINE__); } while(0)
 #define ASSUME(x) /* intentionally left blank */
 #endif
 
+
 #ifdef DEBUGGING
 asm(
     ".pushsection \".debug_gdb_scripts\", \"MS\",@progbits,1\n"