From: Arnaud Giersch Date: Tue, 2 Oct 2012 12:37:30 +0000 (+0200) Subject: Call __gcov_flush() on abort so that gcda files are correctly written. X-Git-Tag: v3_8~146^2~5^2~2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/8ef000cc45e9b44a69b739fe0c6451f24b1f1645 Call __gcov_flush() on abort so that gcda files are correctly written. This is obviously only activated with enable_coverage=ON. --- diff --git a/buildtools/Cmake/Flags.cmake b/buildtools/Cmake/Flags.cmake index 6a10c8fb9e..3fab3f3cb4 100644 --- a/buildtools/Cmake/Flags.cmake +++ b/buildtools/Cmake/Flags.cmake @@ -54,6 +54,7 @@ if(enable_coverage) find_program(GCOV_PATH gcov) if(GCOV_PATH) SET(COVERAGE_COMMAND "${GCOV_PATH}" CACHE TYPE FILEPATH FORCE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCOVERAGE") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") set(TESH_OPTION --enable-coverage) diff --git a/include/xbt/sysdep.h b/include/xbt/sysdep.h index 696dd69395..4bc927c29d 100644 --- a/include/xbt/sysdep.h +++ b/include/xbt/sysdep.h @@ -31,7 +31,17 @@ SG_BEGIN_DECL() * @{ */ /** @brief Kill the program in silence */ +#ifdef COVERAGE +/* Call __gcov_flush on abort when compiling with coverage options. */ +#define xbt_abort() \ + do { \ + extern void __gcov_flush(void); \ + __gcov_flush(); \ + abort(); \ + } while (0) +#else #define xbt_abort() abort() +#endif /** * @brief Kill the program with an error message