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 |
11 # | 11 # |
12 # This is mostly intended for running the chrome browser interactively. | 12 # This is mostly intended for running the chrome browser interactively. |
13 # To run unit tests, you probably want to run chrome_tests.sh instead. | 13 # To run unit tests, you probably want to run chrome_tests.sh instead. |
14 # That's the script used by the valgrind buildbot. | 14 # That's the script used by the valgrind buildbot. |
15 | 15 |
16 export THISDIR=`dirname $0` | 16 export THISDIR=`dirname $0` |
17 | 17 |
18 setup_memcheck() { | 18 setup_memcheck() { |
19 RUN_COMMAND="valgrind" | 19 RUN_COMMAND="valgrind" |
20 # Prefer a 32-bit gdb if it's available. | 20 GDB=gdb |
21 GDB="/usr/bin/gdb32"; | 21 EXE_INFO=$(file $1) |
22 if [ ! -x $GDB ]; then | 22 if [[ $? -eq 0 ]]; then |
23 GDB="gdb" | 23 # Prefer a gdb that matches the executable if it's available. |
| 24 if [[ "$EXE_INFO" == *32-bit* && -x /usr/bin/gdb32 ]]; then |
| 25 GDB="/usr/bin/gdb32"; |
| 26 elif [[ "$EXE_INFO" == *64-bit* && -x /usr/bin/gdb64 ]]; then |
| 27 GDB="/usr/bin/gdb64"; |
| 28 fi |
24 fi | 29 fi |
25 | 30 |
26 # Prompt to attach gdb when there was an error detected. | 31 # Prompt to attach gdb when there was an error detected. |
27 DEFAULT_TOOL_FLAGS=("--db-command=$GDB -nw %f %p" "--db-attach=yes" \ | 32 DEFAULT_TOOL_FLAGS=("--db-command=$GDB -nw %f %p" "--db-attach=yes" \ |
28 # Keep the registers in gdb in sync with the code. | 33 # Keep the registers in gdb in sync with the code. |
29 "--vex-iropt-precise-memory-exns=yes" \ | 34 "--vex-iropt-precise-memory-exns=yes" \ |
30 # Overwrite newly allocated or freed objects | 35 # Overwrite newly allocated or freed objects |
31 # with 0x41 to catch inproper use. | 36 # with 0x41 to catch inproper use. |
32 "--malloc-fill=41" "--free-fill=41" \ | 37 "--malloc-fill=41" "--free-fill=41" \ |
33 # Increase the size of stacks being tracked. | 38 # Increase the size of stacks being tracked. |
(...skipping 28 matching lines...) Expand all Loading... |
62 TOOL_NAME="$TMP_STR" | 67 TOOL_NAME="$TMP_STR" |
63 shift | 68 shift |
64 fi | 69 fi |
65 | 70 |
66 if echo "$@" | grep "\-\-tool" ; then | 71 if echo "$@" | grep "\-\-tool" ; then |
67 echo "--tool=TOOL must be the first argument" >&2 | 72 echo "--tool=TOOL must be the first argument" >&2 |
68 exit 1 | 73 exit 1 |
69 fi | 74 fi |
70 | 75 |
71 case $TOOL_NAME in | 76 case $TOOL_NAME in |
72 memcheck*) setup_memcheck;; | 77 memcheck*) setup_memcheck "$1";; |
73 tsan*) setup_tsan;; | 78 tsan*) setup_tsan;; |
74 *) setup_unknown;; | 79 *) setup_unknown;; |
75 esac | 80 esac |
76 | 81 |
77 | 82 |
78 SUPPRESSIONS="$THISDIR/$TOOL_NAME/suppressions.txt" | 83 SUPPRESSIONS="$THISDIR/$TOOL_NAME/suppressions.txt" |
79 | 84 |
80 CHROME_VALGRIND=`sh $THISDIR/locate_valgrind.sh` | 85 CHROME_VALGRIND=`sh $THISDIR/locate_valgrind.sh` |
81 if [ "$CHROME_VALGRIND" = "" ] | 86 if [ "$CHROME_VALGRIND" = "" ] |
82 then | 87 then |
(...skipping 26 matching lines...) Expand all Loading... |
109 G_SLICE=always-malloc \ | 114 G_SLICE=always-malloc \ |
110 NSS_DISABLE_UNLOAD=1 \ | 115 NSS_DISABLE_UNLOAD=1 \ |
111 NSS_DISABLE_ARENA_FREE_LIST=1 \ | 116 NSS_DISABLE_ARENA_FREE_LIST=1 \ |
112 G_DEBUG=fatal_warnings \ | 117 G_DEBUG=fatal_warnings \ |
113 GTEST_DEATH_TEST_USE_FORK=1 \ | 118 GTEST_DEATH_TEST_USE_FORK=1 \ |
114 $RUN_COMMAND \ | 119 $RUN_COMMAND \ |
115 --trace-children=yes \ | 120 --trace-children=yes \ |
116 --suppressions="$SUPPRESSIONS" \ | 121 --suppressions="$SUPPRESSIONS" \ |
117 "${DEFAULT_TOOL_FLAGS[@]}" \ | 122 "${DEFAULT_TOOL_FLAGS[@]}" \ |
118 "$@" | 123 "$@" |
OLD | NEW |