Merge pull request #23000 from mrc0mmand/coverage__exit

macro: call __gcov_dump() before _exit() w/ coverage enabled
This commit is contained in:
Frantisek Sumsal
2022-04-07 13:08:55 +00:00
committed by GitHub
4 changed files with 22 additions and 2 deletions
+13
View File
@@ -29,6 +29,19 @@
#define _alignptr_ __attribute__((__aligned__(sizeof(void*))))
#define _warn_unused_result_ __attribute__((__warn_unused_result__))
#if defined(BUILT_WITH_COVERAGE) && BUILT_WITH_COVERAGE
/* We need to explicitly call __gcov_dump() in places where we use _exit(), since
* _exit() skips at-exit hooks resulting in lost coverage */
# include <unistd.h>
extern void __gcov_dump(void);
_noreturn_ static inline void _coverage__exit(int status) {
__gcov_dump();
_exit(status);
}
# define _exit(x) _coverage__exit(x)
#endif
#if !defined(HAS_FEATURE_MEMORY_SANITIZER)
# if defined(__has_feature)
# if __has_feature(memory_sanitizer)