summaryrefslogtreecommitdiffstats
path: root/tools/valgrind/valgrind.sh
diff options
context:
space:
mode:
authordkegel@google.com <dkegel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-16 15:55:52 +0000
committerdkegel@google.com <dkegel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-16 15:55:52 +0000
commit68e3b47230aa88a848ba6cb7daee852993f51a62 (patch)
tree15203472cb668e0a6277c99a1ed1c5b0d67fec2c /tools/valgrind/valgrind.sh
parent9229b2de068f352b3d184996206870d1d4ffc2b5 (diff)
downloadchromium_src-68e3b47230aa88a848ba6cb7daee852993f51a62.zip
chromium_src-68e3b47230aa88a848ba6cb7daee852993f51a62.tar.gz
chromium_src-68e3b47230aa88a848ba6cb7daee852993f51a62.tar.bz2
Patch from timurrrr: Re-factor valgrind scripts to add tsan support
First reviewed at http://codereview.chromium.org/125272 BUG=none TEST=none Review URL: http://codereview.chromium.org/155528 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20870 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/valgrind/valgrind.sh')
-rwxr-xr-xtools/valgrind/valgrind.sh59
1 files changed, 49 insertions, 10 deletions
diff --git a/tools/valgrind/valgrind.sh b/tools/valgrind/valgrind.sh
index 0170038..94e571e 100755
--- a/tools/valgrind/valgrind.sh
+++ b/tools/valgrind/valgrind.sh
@@ -12,6 +12,31 @@
# To run unit tests, you probably want to run chrome_tests.sh instead.
# That's the script used by the valgrind buildbot.
+setup_memcheck() {
+ # Prefer a 32-bit gdb if it's available.
+ GDB="/usr/bin/gdb32";
+ if [ ! -x $GDB ]; then
+ GDB="gdb"
+ fi
+
+ # Prompt to attach gdb when there was an error detected.
+ DEFAULT_TOOL_FLAGS=("--db-command=$GDB -nw %f %p" "--db-attach=yes" \
+ # Overwrite newly allocated or freed objects
+ # with 0x41 to catch inproper use.
+ "--malloc-fill=41" "--free-fill=41")
+}
+
+setup_tsan() {
+ IGNORE_FILE="$(cd `dirname "$0"` && pwd)/tsan/ignores.txt"
+ DEFAULT_TOOL_FLAGS=("--announce-threads" "--pure-happens-before=yes" \
+ "--ignore=$IGNORE_FILE")
+}
+
+setup_unknown() {
+ echo "Unknown tool \"$TOOL_NAME\" specified, the result is not guaranteed"
+ DEFAULT_TOOL_FLAGS=()
+}
+
set -e
if [ $# -eq 0 ]; then
@@ -19,21 +44,36 @@ if [ $# -eq 0 ]; then
exit 1
fi
-# Prefer a 32-bit gdb if it's available.
-GDB="/usr/bin/gdb32";
-if [ ! -x $GDB ]; then
- GDB="gdb"
+TOOL_NAME="memcheck"
+declare -a DEFAULT_TOOL_FLAGS[0]
+
+# Select a tool different from memcheck with --tool=TOOL as a first argument
+TMP_STR=`echo $1 | sed 's/^\-\-tool=//'`
+if [ "$TMP_STR" != "$1" ]; then
+ TOOL_NAME="$TMP_STR"
+ shift
+fi
+
+if echo "$@" | grep "\-\-tool" ; then
+ echo "--tool=TOOL must be the first argument" >&2
+ exit 1
fi
+case $TOOL_NAME in
+ memcheck*) setup_memcheck;;
+ tsan*) setup_tsan;;
+ *) setup_unknown;;
+esac
+
# Prefer a local install of valgrind if it's available.
VALGRIND="/usr/local/bin/valgrind"
if [ ! -x $VALGRIND ]; then
VALGRIND="valgrind"
fi
-SUPPRESSIONS="$(cd `dirname "$0"` && pwd)/suppressions.txt"
+SUPPRESSIONS="$(cd `dirname "$0"` && pwd)/$TOOL_NAME/suppressions.txt"
-set -v
+set -x
# Pass GTK glib allocations through to system malloc so valgrind sees them.
# Prevent NSS from recycling memory arenas so valgrind can track origins.
@@ -41,15 +81,14 @@ set -v
# Overwrite newly allocated or freed objects with 0x41 to catch inproper use.
# smc-check=all is required for valgrind to see v8's dynamic code generation.
# trace-children to follow into the renderer processes.
-# Prompt to attach gdb when there was an error detected.
+
G_SLICE=always-malloc \
NSS_DISABLE_ARENA_FREE_LIST=1 \
G_DEBUG=fatal_warnings \
"$VALGRIND" \
+ --tool=$TOOL_NAME \
--trace-children=yes \
- --db-command="$GDB -nw %f %p" \
- --db-attach=yes \
--suppressions="$SUPPRESSIONS" \
- --malloc-fill=41 --free-fill=41 \
--smc-check=all \
+ "${DEFAULT_TOOL_FLAGS[@]}" \
"$@"