diff options
author | Monty <monty@mariadb.org> | 2021-05-20 15:46:06 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2021-05-24 21:04:40 +0300 |
commit | 3b8d4180d5f7f8c0d72be734f13a8de05ef537cb (patch) | |
tree | dbfa8df2e42a53927605253309a5cfc14da766c2 | |
parent | e0a6cfb38b781474169f06478dbfe7800f9657ce (diff) | |
download | mariadb-git-3b8d4180d5f7f8c0d72be734f13a8de05ef537cb.tar.gz |
Flush gcov files for DBUG_ASSERT and DBUG_SUICIDE
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | dbug/dbug.c | 12 | ||||
-rwxr-xr-x | mysql-test/dgcov.pl | 2 |
3 files changed, 14 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ceb9986693..7072214ba23 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -269,7 +269,7 @@ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DENABLED_DEBUG_SYNC") OPTION(ENABLE_GCOV "Enable gcov (debug, Linux builds only)" OFF) IF (ENABLE_GCOV) - MY_CHECK_AND_SET_COMPILER_FLAG("-fprofile-arcs -ftest-coverage -lgcov" DEBUG) + MY_CHECK_AND_SET_COMPILER_FLAG("-DHAVE_gcov -fprofile-arcs -ftest-coverage -lgcov" DEBUG) ENDIF() OPTION(WITHOUT_PACKED_SORT_KEYS "disable packed sort keys" OFF) diff --git a/dbug/dbug.c b/dbug/dbug.c index 011b932a721..5c05994fb4e 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -85,6 +85,9 @@ #undef SAFE_MUTEX #include <m_string.h> #include <errno.h> +#ifdef HAVE_gcov +extern void __gcov_flush(); +#endif #ifndef DBUG_OFF @@ -2209,6 +2212,9 @@ void _db_suicide_() fprintf(stderr, "SIGKILL myself\n"); fflush(stderr); +#ifdef HAVE_gcov + __gcov_flush(); +#endif retval= kill(getpid(), SIGKILL); assert(retval == 0); @@ -2253,7 +2259,13 @@ my_bool _db_my_assert(const char *file, int line, const char *msg) my_bool a = my_assert; _db_flush_(); if (!a) + { fprintf(stderr, "%s:%d: assert: %s\n", file, line, msg); + fflush(stderr); +#ifdef HAVE_gcov + __gcov_flush(); +#endif + } return a; } #else diff --git a/mysql-test/dgcov.pl b/mysql-test/dgcov.pl index fbc5540e697..f04c73969b5 100755 --- a/mysql-test/dgcov.pl +++ b/mysql-test/dgcov.pl @@ -63,7 +63,7 @@ my $cmd; if ($opt_purge) { $cmd= "find . -name '*.da' -o -name '*.gcda' -o -name '*.gcov' -o ". - "-name '*.dgcov' | grep -v 'README\.gcov' | xargs rm -f ''"; + "-name '*.dgcov' | xargs rm -f ''"; logv "Running: $cmd"; system($cmd)==0 or die "system($cmd): $? $!"; exit 0; |