Dump gcov coverage in process_spawn (#10230)

Fixes https://github.com/neovim/neovim/pull/3926#issuecomment-502343527.
This commit is contained in:
Daniel Hahler
2019-06-15 18:30:04 +02:00
committed by GitHub
parent 2f1a653a84
commit d3d25f957d
2 changed files with 11 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ if(USE_GCOV)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage")
add_compile_definitions(USE_GCOV)
endif() endif()
endif() endif()

View File

@@ -22,6 +22,11 @@
# include "event/process.c.generated.h" # include "event/process.c.generated.h"
#endif #endif
/// Externally defined with gcov.
#ifdef USE_GCOV
void __gcov_dump(void);
#endif
// Time for a process to exit cleanly before we send KILL. // Time for a process to exit cleanly before we send KILL.
// For PTY processes SIGTERM is sent first (in case SIGHUP was not enough). // For PTY processes SIGTERM is sent first (in case SIGHUP was not enough).
#define KILL_TIMEOUT_MS 2000 #define KILL_TIMEOUT_MS 2000
@@ -50,6 +55,11 @@ int process_spawn(Process *proc, bool in, bool out, bool err)
proc->err.closed = true; proc->err.closed = true;
} }
#ifdef USE_GCOV
// Dump coverage data before forking, to avoid "Merge mismatch" errors.
__gcov_dump();
#endif
int status; int status;
switch (proc->type) { switch (proc->type) {
case kProcessTypeUv: case kProcessTypeUv: