Add USE_GCOV cmake option
Enabling this option adds --coverage to compilation flags and dumps coverage data (*.gcda) files in flushAndExit. Otherwise coverage data would not be dumped in flushAndExit. Applications that exit more normally (e.g. returning from main) don't need special changes to dump coverage data. This is still experimental and we don't exactly have a plan for running this in CI e.g., so this change just adds the option. Tested with clang11
This commit is contained in:
parent
24ea35e56f
commit
68de888fb4
|
@ -8,8 +8,9 @@ env_set(VALGRIND_ARENA OFF BOOL "Inform valgrind about arena-allocated memory. M
|
|||
env_set(ALLOC_INSTRUMENTATION OFF BOOL "Instrument alloc")
|
||||
env_set(WITH_UNDODB OFF BOOL "Use rr or undodb")
|
||||
env_set(USE_ASAN OFF BOOL "Compile with address sanitizer")
|
||||
env_set(USE_UBSAN OFF BOOL "Compile with undefined behavior sanitizer")
|
||||
env_set(USE_GCOV OFF BOOL "Compile with gcov instrumentation")
|
||||
env_set(USE_TSAN OFF BOOL "Compile with thread sanitizer")
|
||||
env_set(USE_UBSAN OFF BOOL "Compile with undefined behavior sanitizer")
|
||||
env_set(FDB_RELEASE OFF BOOL "This is a building of a final release")
|
||||
env_set(USE_CCACHE OFF BOOL "Use ccache for compilation if available")
|
||||
env_set(RELATIVE_DEBUG_PATHS OFF BOOL "Use relative file paths in debug info")
|
||||
|
@ -170,6 +171,13 @@ else()
|
|||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address ${CMAKE_THREAD_LIBS_INIT}")
|
||||
endif()
|
||||
|
||||
if(USE_GCOV)
|
||||
add_compile_options(--coverage -DUSE_GCOV)
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --coverage")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
|
||||
endif()
|
||||
|
||||
if(USE_UBSAN)
|
||||
add_compile_options(
|
||||
-fsanitize=undefined
|
||||
|
|
|
@ -2968,10 +2968,17 @@ extern "C" void criticalError(int exitCode, const char *type, const char *messag
|
|||
|
||||
extern void flushTraceFileVoid();
|
||||
|
||||
#ifdef USE_GCOV
|
||||
extern "C" void __gcov_flush();
|
||||
#endif
|
||||
|
||||
extern "C" void flushAndExit(int exitCode) {
|
||||
flushTraceFileVoid();
|
||||
fflush(stdout);
|
||||
closeTraceFile();
|
||||
#ifdef USE_GCOV
|
||||
__gcov_flush();
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
// This function is documented as being asynchronous, but we suspect it might actually be synchronous in the
|
||||
// case that it is passed a handle to the current process. If not, then there may be cases where we escalate
|
||||
|
|
Loading…
Reference in New Issue