Add --track-destroy=yes to valgrind_cmd when --tool=helgrind.  This
reports missing pthread_{mutex,rwlock}_destroy calls when a lock is
initialized at the address of a live rwlock or mutex.

Signed-off-by: Aaron Merey <[email protected]>
---
 configure.ac      | 12 ++++++++++++
 tests/Makefile.am |  3 ++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 80c7fd8b..fbe039d5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -405,6 +405,18 @@ fi
 AM_CONDITIONAL(USE_VALGRIND, test "$use_valgrind" = yes -o "$use_helgrind" = 
yes)
 AM_CONDITIONAL(USE_HELGRIND, test "$use_helgrind" = yes)
 
+HELGRIND_TRACK_DESTROY=
+if test "$use_helgrind" = yes; then
+  AC_MSG_CHECKING([whether helgrind supports --track-destroy])
+  if valgrind --tool=helgrind --help | grep -qe "--track-destroy"; then
+    HELGRIND_TRACK_DESTROY="--track-destroy=yes"
+    AC_MSG_RESULT([yes])
+  else
+    AC_MSG_RESULT([no])
+  fi
+fi
+AC_SUBST([HELGRIND_TRACK_DESTROY])
+
 AC_ARG_WITH([valgrind],
 AS_HELP_STRING([--with-valgrind],[include directory for Valgrind headers]),
 [with_valgrind_headers=$withval], [with_valgrind_headers=no])
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9a005416..8ae7d126 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -722,7 +722,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \
 
 
 if USE_HELGRIND
-valgrind_cmd=valgrind -q --tool=helgrind --error-exitcode=1 --track-fds=yes
+valgrind_cmd=valgrind -q --tool=helgrind --error-exitcode=1 --track-fds=yes \
+       @HELGRIND_TRACK_DESTROY@
 else
 if USE_VALGRIND
 valgrind_cmd=valgrind -q --leak-check=full --error-exitcode=1 --track-fds=yes
-- 
2.54.0

Reply via email to