README-valgrind 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #! /bin/bash
  2. # Convert this package for use with valgrind.
  3. # Copyright (C) 2002-2018 Free Software Foundation, Inc.
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. # You should have received a copy of the GNU General Public License
  13. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. # Convert Makefile.am files:
  15. # find tests -name check.mk | xargs grep -wl PATH |
  16. # xargs perl -pi -e 's,src(\$\(PATH_SEPARATOR\)),src/vg$1,'
  17. # To restore:
  18. # find tests -name check.mk | xargs grep -wl PATH |
  19. # xargs perl -pi -e 's,src/vg,src,'
  20. #
  21. # Create this symlink for suppressions (this is no longer necessary,
  22. # with Linux kernel 2.6.9 and valgrind-2.2.0):
  23. # ln -s $PWD/.vg-suppressions /tmp/cu-vg
  24. # Create src/vg:
  25. coreutils=$(echo 'spy:;@echo $(all_programs) $(noinst_PROGRAMS)' |
  26. (cd src; make -f Makefile -f - spy | tr -s '\n ' ' '))
  27. mkdir -p src/vg
  28. pwd=`pwd`
  29. srcdir=$pwd/src
  30. _path='export PATH='$srcdir':${PATH#*:}'
  31. pre='#!/bin/sh\n'"$_path"'\n'
  32. n=15 # stack trace depth
  33. log_fd=3 # One can redirect this to file like 3>vg.log
  34. test -e /tmp/cu-vg && suppressions='--supressions=/tmp/cu-vg'
  35. vg="exec /usr/bin/valgrind $suppressions --log-fd=$log_fd \
  36. --leak-check=yes --track-fds=yes --leak-check=full --num-callers=$n"
  37. cat <<EOF > src/vg/gen
  38. for i in $coreutils; do
  39. printf "$pre$vg -- \$i"' "\$@"\n' > \$i
  40. chmod a+x \$i
  41. done
  42. EOF
  43. cd src/vg
  44. . ./gen