sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Should point to the installation directory |
| 4 | prefix="@prefix@" |
| 5 | exec_prefix="@exec_prefix@" |
| 6 | VALGRIND="@libdir@/valgrind" |
| 7 | |
| 8 | |
| 9 | # Other stuff ... |
| 10 | version="@VERSION@" |
| 11 | emailto="jseward@acm.org" |
| 12 | |
| 13 | # The default name of the suppressions file |
| 14 | vgsupp="--suppressions=$VALGRIND/default.supp" |
| 15 | |
| 16 | # name we were invoked with |
| 17 | vgname=`echo $0 | sed 's,^.*/,,'` |
| 18 | |
| 19 | # Valgrind options |
| 20 | vgopts= |
| 21 | |
| 22 | # Prog and arg to run |
| 23 | argopts= |
| 24 | |
| 25 | # Show usage info? |
| 26 | dousage=0 |
| 27 | |
| 28 | # show version info? |
| 29 | doversion=0 |
| 30 | |
| 31 | # Collect up args for Valgrind |
sewardj | 557fb85 | 2002-04-22 22:26:51 +0000 | [diff] [blame] | 32 | while [ $+ != 0 ] |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 33 | do |
sewardj | 557fb85 | 2002-04-22 22:26:51 +0000 | [diff] [blame] | 34 | arg=$1 |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 35 | case "$arg" in |
| 36 | # options for the user |
| 37 | --help) dousage=1; break;; |
| 38 | --version) doversion=1; break;; |
| 39 | --logfile-fd=*) vgopts="$vgopts $arg"; shift;; |
| 40 | -v) vgopts="$vgopts $arg"; shift;; |
| 41 | --verbose) vgopts="$vgopts -v"; shift;; |
| 42 | -q) vgopts="$vgopts $arg"; shift;; |
| 43 | --quiet) vgopts="$vgopts $arg"; shift;; |
sewardj | 97ced73 | 2002-03-25 00:07:36 +0000 | [diff] [blame] | 44 | --check-addrVs=no) vgopts="$vgopts $arg"; shift;; |
| 45 | --check-addrVs=yes) vgopts="$vgopts $arg"; shift;; |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 46 | --gdb-attach=no) vgopts="$vgopts $arg"; shift;; |
| 47 | --gdb-attach=yes) vgopts="$vgopts $arg"; shift;; |
| 48 | --demangle=no) vgopts="$vgopts $arg"; shift;; |
| 49 | --demangle=yes) vgopts="$vgopts $arg"; shift;; |
| 50 | --num-callers=*) vgopts="$vgopts $arg"; shift;; |
| 51 | --partial-loads-ok=no) vgopts="$vgopts $arg"; shift;; |
| 52 | --partial-loads-ok=yes) vgopts="$vgopts $arg"; shift;; |
| 53 | --leak-check=no) vgopts="$vgopts $arg"; shift;; |
| 54 | --leak-check=yes) vgopts="$vgopts $arg"; shift;; |
| 55 | --show-reachable=no) vgopts="$vgopts $arg"; shift;; |
| 56 | --show-reachable=yes) vgopts="$vgopts $arg"; shift;; |
| 57 | --leak-resolution=low) vgopts="$vgopts $arg"; shift;; |
| 58 | --leak-resolution=med) vgopts="$vgopts $arg"; shift;; |
| 59 | --leak-resolution=high) vgopts="$vgopts $arg"; shift;; |
| 60 | --sloppy-malloc=no) vgopts="$vgopts $arg"; shift;; |
| 61 | --sloppy-malloc=yes) vgopts="$vgopts $arg"; shift;; |
| 62 | --trace-children=no) vgopts="$vgopts $arg"; shift;; |
| 63 | --trace-children=yes) vgopts="$vgopts $arg"; shift;; |
| 64 | --workaround-gcc296-bugs=no) vgopts="$vgopts $arg"; shift;; |
| 65 | --workaround-gcc296-bugs=yes) vgopts="$vgopts $arg"; shift;; |
| 66 | --freelist-vol=*) vgopts="$vgopts $arg"; shift;; |
| 67 | --suppressions=*) vgopts="$vgopts $arg"; shift;; |
njn | 4f9c934 | 2002-04-29 16:03:24 +0000 | [diff] [blame] | 68 | --cachesim=yes) vgopts="$vgopts $arg"; shift;; |
| 69 | --cachesim=no) vgopts="$vgopts $arg"; shift;; |
sewardj | 3984b85 | 2002-05-12 03:00:17 +0000 | [diff] [blame^] | 70 | --wierd-hacks=*) vgopts="$vgopts $arg"; shift;; |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 71 | # options for debugging Valgrind |
| 72 | --sanity-level=*) vgopts="$vgopts $arg"; shift;; |
| 73 | --single-step=yes) vgopts="$vgopts $arg"; shift;; |
| 74 | --single-step=no) vgopts="$vgopts $arg"; shift;; |
| 75 | --optimise=yes) vgopts="$vgopts $arg"; shift;; |
| 76 | --optimise=no) vgopts="$vgopts $arg"; shift;; |
| 77 | --instrument=yes) vgopts="$vgopts $arg"; shift;; |
| 78 | --instrument=no) vgopts="$vgopts $arg"; shift;; |
| 79 | --cleanup=yes) vgopts="$vgopts $arg"; shift;; |
| 80 | --cleanup=no) vgopts="$vgopts $arg"; shift;; |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 81 | --smc-check=none) vgopts="$vgopts $arg"; shift;; |
| 82 | --smc-check=some) vgopts="$vgopts $arg"; shift;; |
| 83 | --smc-check=all) vgopts="$vgopts $arg"; shift;; |
| 84 | --trace-syscalls=yes) vgopts="$vgopts $arg"; shift;; |
| 85 | --trace-syscalls=no) vgopts="$vgopts $arg"; shift;; |
| 86 | --trace-signals=yes) vgopts="$vgopts $arg"; shift;; |
| 87 | --trace-signals=no) vgopts="$vgopts $arg"; shift;; |
| 88 | --trace-symtab=yes) vgopts="$vgopts $arg"; shift;; |
| 89 | --trace-symtab=no) vgopts="$vgopts $arg"; shift;; |
| 90 | --trace-malloc=yes) vgopts="$vgopts $arg"; shift;; |
| 91 | --trace-malloc=no) vgopts="$vgopts $arg"; shift;; |
sewardj | 8937c81 | 2002-04-12 20:12:20 +0000 | [diff] [blame] | 92 | --trace-sched=yes) vgopts="$vgopts $arg"; shift;; |
| 93 | --trace-sched=no) vgopts="$vgopts $arg"; shift;; |
sewardj | 45b4b37 | 2002-04-16 22:50:32 +0000 | [diff] [blame] | 94 | --trace-pthread=none) vgopts="$vgopts $arg"; shift;; |
| 95 | --trace-pthread=some) vgopts="$vgopts $arg"; shift;; |
| 96 | --trace-pthread=all) vgopts="$vgopts $arg"; shift;; |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 97 | --stop-after=*) vgopts="$vgopts $arg"; shift;; |
| 98 | --dump-error=*) vgopts="$vgopts $arg"; shift;; |
| 99 | -*) dousage=1; break;; |
| 100 | *) break;; |
| 101 | esac |
| 102 | done |
| 103 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 104 | if [ z"$doversion" = z1 ]; then |
| 105 | echo "valgrind-$version" |
| 106 | exit 1 |
| 107 | fi |
| 108 | |
sewardj | 557fb85 | 2002-04-22 22:26:51 +0000 | [diff] [blame] | 109 | if [ $# = 0 ] || [ z"$dousage" = z1 ]; then |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 110 | echo |
| 111 | echo "usage: $vgname [options] prog-and-args" |
| 112 | echo |
| 113 | echo " options for the user, with defaults in [ ], are:" |
| 114 | echo " --help show this message" |
| 115 | echo " --version show version" |
| 116 | echo " -q --quiet run silently; only print error msgs" |
| 117 | echo " -v --verbose be more verbose, incl counts of errors" |
| 118 | echo " --gdb-attach=no|yes start GDB when errors detected? [no]" |
| 119 | echo " --demangle=no|yes automatically demangle C++ names? [yes]" |
| 120 | echo " --num-callers=<number> show <num> callers in stack traces [4]" |
| 121 | echo " --partial-loads-ok=no|yes too hard to explain here; see manual [yes]" |
| 122 | echo " --leak-check=no|yes search for memory leaks at exit? [no]" |
| 123 | echo " --leak-resolution=low|med|high" |
| 124 | echo " amount of bt merging in leak check [low]" |
| 125 | echo " --show-reachable=no|yes show reachable blocks in leak check? [no]" |
| 126 | echo " --sloppy-malloc=no|yes round malloc sizes to next word? [no]" |
| 127 | echo " --trace-children=no|yes Valgrind-ise child processes? [no]" |
| 128 | echo " --logfile-fd=<number> file descriptor for messages [2=stderr]" |
| 129 | echo " --freelist-vol=<number> volume of freed blocks queue [1000000]" |
| 130 | echo " --workaround-gcc296-bugs=no|yes self explanatory [no]" |
| 131 | echo " --suppressions=<filename> suppress errors described in" |
| 132 | echo " suppressions file <filename>" |
sewardj | 97ced73 | 2002-03-25 00:07:36 +0000 | [diff] [blame] | 133 | echo " --check-addrVs=no|yes experimental lighterweight checking? [yes]" |
| 134 | echo " yes == Valgrind's original behaviour" |
njn | 4f9c934 | 2002-04-29 16:03:24 +0000 | [diff] [blame] | 135 | echo " --cachesim=no|yes do cache profiling? [no]" |
sewardj | 3984b85 | 2002-05-12 03:00:17 +0000 | [diff] [blame^] | 136 | echo " --wierd-hacks=hack1,hack2,... [no hacks selected]" |
| 137 | echo " recognised hacks are: ioctl-VTIME" |
| 138 | echo "" |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 139 | echo |
| 140 | echo " options for debugging Valgrind itself are:" |
| 141 | echo " --sanity-level=<number> level of sanity checking to do [1]" |
| 142 | echo " --single-step=no|yes translate each instr separately? [no]" |
| 143 | echo " --optimise=no|yes improve intermediate code? [yes]" |
| 144 | echo " --instrument=no|yes actually do memory checks? [yes]" |
| 145 | echo " --cleanup=no|yes improve after instrumentation? [yes]" |
| 146 | echo " --smc-check=none|some|all check writes for s-m-c? [some]" |
| 147 | echo " --trace-syscalls=no|yes show all system calls? [no]" |
| 148 | echo " --trace-signals=no|yes show signal handling details? [no]" |
| 149 | echo " --trace-symtab=no|yes show symbol table details? [no]" |
| 150 | echo " --trace-malloc=no|yes show client malloc details? [no]" |
sewardj | 8937c81 | 2002-04-12 20:12:20 +0000 | [diff] [blame] | 151 | echo " --trace-sched=no|yes show thread scheduler details? [no]" |
sewardj | 45b4b37 | 2002-04-16 22:50:32 +0000 | [diff] [blame] | 152 | echo " --trace-pthread=none|some|all show pthread event details? [no]" |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 153 | echo " --stop-after=<number> switch to real CPU after executing" |
| 154 | echo " <number> basic blocks [infinity]" |
| 155 | echo " --dump-error=<number> show translation for basic block" |
| 156 | echo " associated with <number>'th" |
| 157 | echo " error context [0=don't show any]" |
| 158 | echo |
| 159 | echo " Extra options are read from env variable \$VALGRIND_OPTS" |
| 160 | echo |
| 161 | echo " Valgrind is Copyright (C) 2000-2002 Julian Seward" |
| 162 | echo " and licensed under the GNU General Public License, version 2." |
| 163 | echo " Bug reports, feedback, admiration, abuse, etc, to: $emailto." |
| 164 | echo |
| 165 | exit 1 |
| 166 | fi |
| 167 | |
| 168 | |
| 169 | VG_ARGS="$VALGRIND_OPTS $vgsupp $vgopts" |
| 170 | export VG_ARGS |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 171 | LD_LIBRARY_PATH=$VALGRIND:$LD_LIBRARY_PATH |
| 172 | export LD_LIBRARY_PATH |
| 173 | LD_PRELOAD=valgrind.so:$LD_PRELOAD |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 174 | export LD_PRELOAD |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 175 | #LD_DEBUG=files |
sewardj | 5716dbb | 2002-04-26 03:28:18 +0000 | [diff] [blame] | 176 | #LD_DEBUG=symbols |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 177 | #export LD_DEBUG |
sewardj | 557fb85 | 2002-04-22 22:26:51 +0000 | [diff] [blame] | 178 | exec "$@" |