blob: 40bb6c959d084cec0494955e40f0207e9a478b25 [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;;
sewardjde4a1d02002-03-22 01:27:54 +000077 --smc-check=none) vgopts="$vgopts $arg"; shift;;
78 --smc-check=some) vgopts="$vgopts $arg"; shift;;
79 --smc-check=all) vgopts="$vgopts $arg"; shift;;
80 --trace-syscalls=yes) vgopts="$vgopts $arg"; shift;;
81 --trace-syscalls=no) vgopts="$vgopts $arg"; shift;;
82 --trace-signals=yes) vgopts="$vgopts $arg"; shift;;
83 --trace-signals=no) vgopts="$vgopts $arg"; shift;;
84 --trace-symtab=yes) vgopts="$vgopts $arg"; shift;;
85 --trace-symtab=no) vgopts="$vgopts $arg"; shift;;
86 --trace-malloc=yes) vgopts="$vgopts $arg"; shift;;
87 --trace-malloc=no) vgopts="$vgopts $arg"; shift;;
sewardj8937c812002-04-12 20:12:20 +000088 --trace-sched=yes) vgopts="$vgopts $arg"; shift;;
89 --trace-sched=no) vgopts="$vgopts $arg"; shift;;
sewardj45b4b372002-04-16 22:50:32 +000090 --trace-pthread=none) vgopts="$vgopts $arg"; shift;;
91 --trace-pthread=some) vgopts="$vgopts $arg"; shift;;
92 --trace-pthread=all) vgopts="$vgopts $arg"; shift;;
sewardjde4a1d02002-03-22 01:27:54 +000093 --stop-after=*) vgopts="$vgopts $arg"; shift;;
94 --dump-error=*) vgopts="$vgopts $arg"; shift;;
95 -*) dousage=1; break;;
96 *) break;;
97 esac
98done
99
100# Collect up the prog and args to run
101for arg
102do
103 case "$arg" in
104 *) argopts="$argopts $arg"; shift;;
105 esac
106done
107
108if [ z"$doversion" = z1 ]; then
109 echo "valgrind-$version"
110 exit 1
111fi
112
113if [ z"$argopts" = z -o z"$dousage" = z1 ]; then
114 echo
115 echo "usage: $vgname [options] prog-and-args"
116 echo
117 echo " options for the user, with defaults in [ ], are:"
118 echo " --help show this message"
119 echo " --version show version"
120 echo " -q --quiet run silently; only print error msgs"
121 echo " -v --verbose be more verbose, incl counts of errors"
122 echo " --gdb-attach=no|yes start GDB when errors detected? [no]"
123 echo " --demangle=no|yes automatically demangle C++ names? [yes]"
124 echo " --num-callers=<number> show <num> callers in stack traces [4]"
125 echo " --partial-loads-ok=no|yes too hard to explain here; see manual [yes]"
126 echo " --leak-check=no|yes search for memory leaks at exit? [no]"
127 echo " --leak-resolution=low|med|high"
128 echo " amount of bt merging in leak check [low]"
129 echo " --show-reachable=no|yes show reachable blocks in leak check? [no]"
130 echo " --sloppy-malloc=no|yes round malloc sizes to next word? [no]"
131 echo " --trace-children=no|yes Valgrind-ise child processes? [no]"
132 echo " --logfile-fd=<number> file descriptor for messages [2=stderr]"
133 echo " --freelist-vol=<number> volume of freed blocks queue [1000000]"
134 echo " --workaround-gcc296-bugs=no|yes self explanatory [no]"
135 echo " --suppressions=<filename> suppress errors described in"
136 echo " suppressions file <filename>"
sewardj97ced732002-03-25 00:07:36 +0000137 echo " --check-addrVs=no|yes experimental lighterweight checking? [yes]"
138 echo " yes == Valgrind's original behaviour"
sewardjde4a1d02002-03-22 01:27:54 +0000139 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]"
sewardj8937c812002-04-12 20:12:20 +0000151 echo " --trace-sched=no|yes show thread scheduler details? [no]"
sewardj45b4b372002-04-16 22:50:32 +0000152 echo " --trace-pthread=none|some|all show pthread event details? [no]"
sewardjde4a1d02002-03-22 01:27:54 +0000153 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
166fi
167
168
169VG_ARGS="$VALGRIND_OPTS $vgsupp $vgopts"
170export VG_ARGS
sewardj2e93c502002-04-12 11:12:52 +0000171LD_LIBRARY_PATH=$VALGRIND:$LD_LIBRARY_PATH
172export LD_LIBRARY_PATH
173LD_PRELOAD=valgrind.so:$LD_PRELOAD
sewardjde4a1d02002-03-22 01:27:54 +0000174export LD_PRELOAD
sewardj2e93c502002-04-12 11:12:52 +0000175#LD_DEBUG=files
176#export LD_DEBUG
sewardjde4a1d02002-03-22 01:27:54 +0000177exec $argopts