| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 | 2 |
| 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 # This is a small script for manually launching valgrind, along with passing | 7 # This is a small script for manually launching valgrind, along with passing |
| 8 # it the suppression file, and some helpful arguments (automatically attaching | 8 # it the suppression file, and some helpful arguments (automatically attaching |
| 9 # the debugger on failures, etc). Run it from your repo root, something like: | 9 # the debugger on failures, etc). Run it from your repo root, something like: |
| 10 # $ sh ./tools/valgrind/valgrind.sh ./out/Debug/chrome | 10 # $ sh ./tools/valgrind/valgrind.sh ./out/Debug/chrome |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 DEFAULT_TOOL_FLAGS=("--db-command=gdb -nw %f %p" "--db-attach=yes" \ | 22 DEFAULT_TOOL_FLAGS=("--db-command=gdb -nw %f %p" "--db-attach=yes" \ |
| 23 # Keep the registers in gdb in sync with the code. | 23 # Keep the registers in gdb in sync with the code. |
| 24 "--vex-iropt-register-updates=allregs-at-mem-access" \ | 24 "--vex-iropt-register-updates=allregs-at-mem-access" \ |
| 25 # Overwrite newly allocated or freed objects | 25 # Overwrite newly allocated or freed objects |
| 26 # with 0x41 to catch inproper use. | 26 # with 0x41 to catch inproper use. |
| 27 "--malloc-fill=41" "--free-fill=41" \ | 27 "--malloc-fill=41" "--free-fill=41" \ |
| 28 # Increase the size of stacks being tracked. | 28 # Increase the size of stacks being tracked. |
| 29 "--num-callers=30") | 29 "--num-callers=30") |
| 30 } | 30 } |
| 31 | 31 |
| 32 setup_tsan() { | |
| 33 RUN_COMMAND="valgrind-tsan.sh" | |
| 34 IGNORE_FILE="$THISDIR/tsan/ignores.txt" | |
| 35 DEFAULT_TOOL_FLAGS=("--announce-threads" "--pure-happens-before=yes" \ | |
| 36 "--ignore=$IGNORE_FILE") | |
| 37 } | |
| 38 | |
| 39 setup_unknown() { | 32 setup_unknown() { |
| 40 echo "Unknown tool \"$TOOL_NAME\" specified, the result is not guaranteed" | 33 echo "Unknown tool \"$TOOL_NAME\" specified, the result is not guaranteed" |
| 41 DEFAULT_TOOL_FLAGS=() | 34 DEFAULT_TOOL_FLAGS=() |
| 42 } | 35 } |
| 43 | 36 |
| 44 set -e | 37 set -e |
| 45 | 38 |
| 46 if [ $# -eq 0 ]; then | 39 if [ $# -eq 0 ]; then |
| 47 echo "usage: <command to run> <arguments ...>" | 40 echo "usage: <command to run> <arguments ...>" |
| 48 exit 1 | 41 exit 1 |
| 49 fi | 42 fi |
| 50 | 43 |
| 51 TOOL_NAME="memcheck" | 44 TOOL_NAME="memcheck" |
| 52 declare -a DEFAULT_TOOL_FLAGS[0] | 45 declare -a DEFAULT_TOOL_FLAGS[0] |
| 53 | 46 |
| 54 # Select a tool different from memcheck with --tool=TOOL as a first argument | 47 # Select a tool different from memcheck with --tool=TOOL as a first argument |
| 55 TMP_STR=`echo $1 | sed 's/^\-\-tool=//'` | 48 TMP_STR=`echo $1 | sed 's/^\-\-tool=//'` |
| 56 if [ "$TMP_STR" != "$1" ]; then | 49 if [ "$TMP_STR" != "$1" ]; then |
| 57 TOOL_NAME="$TMP_STR" | 50 TOOL_NAME="$TMP_STR" |
| 58 shift | 51 shift |
| 59 fi | 52 fi |
| 60 | 53 |
| 61 if echo "$@" | grep "\-\-tool" ; then | 54 if echo "$@" | grep "\-\-tool" ; then |
| 62 echo "--tool=TOOL must be the first argument" >&2 | 55 echo "--tool=TOOL must be the first argument" >&2 |
| 63 exit 1 | 56 exit 1 |
| 64 fi | 57 fi |
| 65 | 58 |
| 66 case $TOOL_NAME in | 59 case $TOOL_NAME in |
| 67 memcheck*) setup_memcheck "$1";; | 60 memcheck*) setup_memcheck "$1";; |
| 68 tsan*) setup_tsan;; | |
| 69 *) setup_unknown;; | 61 *) setup_unknown;; |
| 70 esac | 62 esac |
| 71 | 63 |
| 72 | 64 |
| 73 SUPPRESSIONS="$THISDIR/$TOOL_NAME/suppressions.txt" | 65 SUPPRESSIONS="$THISDIR/$TOOL_NAME/suppressions.txt" |
| 74 | 66 |
| 75 CHROME_VALGRIND=`sh $THISDIR/locate_valgrind.sh` | 67 CHROME_VALGRIND=`sh $THISDIR/locate_valgrind.sh` |
| 76 if [ "$CHROME_VALGRIND" = "" ] | 68 if [ "$CHROME_VALGRIND" = "" ] |
| 77 then | 69 then |
| 78 # locate_valgrind.sh failed | 70 # locate_valgrind.sh failed |
| (...skipping 26 matching lines...) Expand all Loading... |
| 105 NSS_DISABLE_UNLOAD=1 \ | 97 NSS_DISABLE_UNLOAD=1 \ |
| 106 NSS_DISABLE_ARENA_FREE_LIST=1 \ | 98 NSS_DISABLE_ARENA_FREE_LIST=1 \ |
| 107 G_DEBUG=fatal_warnings \ | 99 G_DEBUG=fatal_warnings \ |
| 108 GTEST_DEATH_TEST_USE_FORK=1 \ | 100 GTEST_DEATH_TEST_USE_FORK=1 \ |
| 109 $RUN_COMMAND \ | 101 $RUN_COMMAND \ |
| 110 --trace-children=yes \ | 102 --trace-children=yes \ |
| 111 --leak-check=yes \ | 103 --leak-check=yes \ |
| 112 --suppressions="$SUPPRESSIONS" \ | 104 --suppressions="$SUPPRESSIONS" \ |
| 113 "${DEFAULT_TOOL_FLAGS[@]}" \ | 105 "${DEFAULT_TOOL_FLAGS[@]}" \ |
| 114 "$@" | 106 "$@" |
| OLD | NEW |