Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Call __gcov_flush() on abort so that gcda files are correctly written.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Tue, 2 Oct 2012 12:37:30 +0000 (14:37 +0200)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Tue, 2 Oct 2012 12:41:55 +0000 (14:41 +0200)
This is obviously only activated with enable_coverage=ON.

buildtools/Cmake/Flags.cmake
include/xbt/sysdep.h

index 6a10c8f..3fab3f3 100644 (file)
@@ -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)
index 696dd69..4bc927c 100644 (file)
@@ -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