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