Skip to content

Commit

Permalink
Add CMake option to enable assertions irrespective CMAKE_BUILD_TYPE
Browse files Browse the repository at this point in the history
  • Loading branch information
atrosinenko committed Sep 24, 2023
1 parent 3ec8802 commit 5d9331a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ include(runtime/common/Helpers.cmake)
set(KBDYSCH_STANDALONE_C_COMPILER "cc" CACHE STRING "C compiler for non-instrumented standalone executables")
set(KBDYSCH_STANDALONE_CXX_COMPILER "c++" CACHE STRING "C++ compiler for non-instrumented standalone executables")
set(KBDYSCH_PERFORM_AFL_TESTS OFF CACHE BOOL "Perform tests that depend on AFL++")
set(KBDYSCH_ENABLE_ASSERTIONS ON CACHE BOOL "Enable assertions")

if (KBDYSCH_ENABLE_ASSERTIONS)
add_compile_options(-UNDEBUG)
else()
add_compile_options(-DNDEBUG)
endif()

add_definitions(-D_GNU_SOURCE)

Expand Down
9 changes: 5 additions & 4 deletions runtime/mutators/afl-generic-mutator.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#ifdef NDEBUG
#undef NDEBUG
#endif

#include "kbdysch/hashing.h"
#include "kbdysch/mutator-defs.h"
#include "kbdysch/options.h"
Expand Down Expand Up @@ -32,6 +28,11 @@ DECLARE_INT_KNOB_DEF(num_best_effort_iterations,

using namespace kbdysch::mutator;

#ifndef NDEBUG
// Print a better message.
#define abort() assert(0)
#endif

struct mutator_state {
mutator_state();

Expand Down

0 comments on commit 5d9331a

Please sign in to comment.