From 52d81aaaffc692d95ff6ccc6e00ead7fa84bc0b2 Mon Sep 17 00:00:00 2001 From: Leif Hedstrom Date: Tue, 18 May 2021 14:00:37 -0600 Subject: [PATCH] Adds a new --enable-all-asserts configure option --- configure.ac | 20 ++++++++++++++++---- include/tscore/ink_assert.h | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 74b3397d641..137bd2bb389 100644 --- a/configure.ac +++ b/configure.ac @@ -151,7 +151,6 @@ AC_SUBST([build_number]) # # Debug # - AC_MSG_CHECKING([whether to enable debugging]) AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug],[turn on debugging])], @@ -168,6 +167,15 @@ AC_ARG_ENABLE([mime-sanity-check], ) AC_MSG_RESULT([$enable_mime_sanity_check]) +AC_MSG_CHECKING([whether to enable all asserts, a cheaper debug]) +AC_ARG_ENABLE([all-asserts], + [AS_HELP_STRING([--enable-all-asserts],[turn on all code asserts, both debug and release])], + [], + [enable_all_asserts=no] +) +AC_MSG_RESULT([$enable_all_asserts]) + + # Enable code coverage instrumentation only if requested by the user. AC_MSG_CHECKING([whether to code coverage]) AC_ARG_ENABLE([coverage], @@ -957,14 +965,18 @@ if test "x${enable_debug}" = "xyes"; then TS_ADDTO(AM_CFLAGS, [${cc_oflag_dbg}]) TS_ADDTO(AM_CXXFLAGS, [${cxx_oflag_dbg}]) TS_ADDTO(AM_CPPFLAGS, [-DDEBUG -D_DEBUG]) - if test "x${enable_mime_sanity_check}" = "xyes"; then - TS_ADDTO(AM_CPPFLAGS, [-DENABLE_MIME_SANITY_CHECK]) - fi else TS_ADDTO(AM_CFLAGS, [${cc_oflag_opt}]) TS_ADDTO(AM_CXXFLAGS, [${cxx_oflag_opt}]) fi +if test "x${enable_mime_sanity_check}" = "xyes"; then + TS_ADDTO(AM_CPPFLAGS, [-DENABLE_MIME_SANITY_CHECK]) +fi +if test "x${enable_all_asserts}" = "xyes"; then + TS_ADDTO(AM_CPPFLAGS, [-DENABLE_ALL_ASSERTS]) +fi + # Flags for ASAN if test "x${enable_asan}" = "xyes"; then if test "x${enable_tsan}" = "xyes" -o "x${enable_tsan}" = "xstatic"; then diff --git a/include/tscore/ink_assert.h b/include/tscore/ink_assert.h index bad4a86dc10..b851e082063 100644 --- a/include/tscore/ink_assert.h +++ b/include/tscore/ink_assert.h @@ -43,7 +43,7 @@ extern "C" { inkcoreapi void _ink_assert(const char *a, const char *f, int l) TS_NORETURN; -#if defined(DEBUG) || defined(__clang_analyzer__) || defined(__COVERITY__) +#if defined(DEBUG) || defined(ENABLE_ALL_ASSERTS) || defined(__clang_analyzer__) || defined(__COVERITY__) #define ink_assert(EX) ((void)(__builtin_expect(!!(EX), 1) ? (void)0 : _ink_assert(#EX, __FILE__, __LINE__))) #else #define ink_assert(EX) (void)(EX)