blob: f791c663ad2d81bf031a2014a9e337f411bfbec6 [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;;
43 --gdb-attach=no) vgopts="$vgopts $arg"; shift;;
44 --gdb-attach=yes) vgopts="$vgopts $arg"; shift;;
45 --demangle=no) vgopts="$vgopts $arg"; shift;;
46 --demangle=yes) vgopts="$vgopts $arg"; shift;;
47 --num-callers=*) vgopts="$vgopts $arg"; shift;;
48 --partial-loads-ok=no) vgopts="$vgopts $arg"; shift;;
49 --partial-loads-ok=yes) vgopts="$vgopts $arg"; shift;;
50 --leak-check=no) vgopts="$vgopts $arg"; shift;;
51 --leak-check=yes) vgopts="$vgopts $arg"; shift;;
52 --show-reachable=no) vgopts="$vgopts $arg"; shift;;
53 --show-reachable=yes) vgopts="$vgopts $arg"; shift;;
54 --leak-resolution=low) vgopts="$vgopts $arg"; shift;;
55 --leak-resolution=med) vgopts="$vgopts $arg"; shift;;
56 --leak-resolution=high) vgopts="$vgopts $arg"; shift;;
57 --sloppy-malloc=no) vgopts="$vgopts $arg"; shift;;
58 --sloppy-malloc=yes) vgopts="$vgopts $arg"; shift;;
59 --trace-children=no) vgopts="$vgopts $arg"; shift;;
60 --trace-children=yes) vgopts="$vgopts $arg"; shift;;
61 --workaround-gcc296-bugs=no) vgopts="$vgopts $arg"; shift;;
62 --workaround-gcc296-bugs=yes) vgopts="$vgopts $arg"; shift;;
63 --freelist-vol=*) vgopts="$vgopts $arg"; shift;;
64 --suppressions=*) vgopts="$vgopts $arg"; shift;;
65# options for debugging Valgrind
66 --sanity-level=*) vgopts="$vgopts $arg"; shift;;
67 --single-step=yes) vgopts="$vgopts $arg"; shift;;
68 --single-step=no) vgopts="$vgopts $arg"; shift;;
69 --optimise=yes) vgopts="$vgopts $arg"; shift;;
70 --optimise=no) vgopts="$vgopts $arg"; shift;;
71 --instrument=yes) vgopts="$vgopts $arg"; shift;;
72 --instrument=no) vgopts="$vgopts $arg"; shift;;
73 --cleanup=yes) vgopts="$vgopts $arg"; shift;;
74 --cleanup=no) vgopts="$vgopts $arg"; shift;;
75 --client-perms=yes) vgopts="$vgopts $arg"; shift;;
76 --client-perms=no) vgopts="$vgopts $arg"; shift;;
77 --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;;
88 --stop-after=*) vgopts="$vgopts $arg"; shift;;
89 --dump-error=*) vgopts="$vgopts $arg"; shift;;
90 -*) dousage=1; break;;
91 *) break;;
92 esac
93done
94
95# Collect up the prog and args to run
96for arg
97do
98 case "$arg" in
99 *) argopts="$argopts $arg"; shift;;
100 esac
101done
102
103if [ z"$doversion" = z1 ]; then
104 echo "valgrind-$version"
105 exit 1
106fi
107
108if [ z"$argopts" = z -o z"$dousage" = z1 ]; then
109 echo
110 echo "usage: $vgname [options] prog-and-args"
111 echo
112 echo " options for the user, with defaults in [ ], are:"
113 echo " --help show this message"
114 echo " --version show version"
115 echo " -q --quiet run silently; only print error msgs"
116 echo " -v --verbose be more verbose, incl counts of errors"
117 echo " --gdb-attach=no|yes start GDB when errors detected? [no]"
118 echo " --demangle=no|yes automatically demangle C++ names? [yes]"
119 echo " --num-callers=<number> show <num> callers in stack traces [4]"
120 echo " --partial-loads-ok=no|yes too hard to explain here; see manual [yes]"
121 echo " --leak-check=no|yes search for memory leaks at exit? [no]"
122 echo " --leak-resolution=low|med|high"
123 echo " amount of bt merging in leak check [low]"
124 echo " --show-reachable=no|yes show reachable blocks in leak check? [no]"
125 echo " --sloppy-malloc=no|yes round malloc sizes to next word? [no]"
126 echo " --trace-children=no|yes Valgrind-ise child processes? [no]"
127 echo " --logfile-fd=<number> file descriptor for messages [2=stderr]"
128 echo " --freelist-vol=<number> volume of freed blocks queue [1000000]"
129 echo " --workaround-gcc296-bugs=no|yes self explanatory [no]"
130 echo " --suppressions=<filename> suppress errors described in"
131 echo " suppressions file <filename>"
132 echo " --client-perms=no|yes handle client VG_MAKE_* requests? [no]"
133 echo
134 echo " options for debugging Valgrind itself are:"
135 echo " --sanity-level=<number> level of sanity checking to do [1]"
136 echo " --single-step=no|yes translate each instr separately? [no]"
137 echo " --optimise=no|yes improve intermediate code? [yes]"
138 echo " --instrument=no|yes actually do memory checks? [yes]"
139 echo " --cleanup=no|yes improve after instrumentation? [yes]"
140 echo " --smc-check=none|some|all check writes for s-m-c? [some]"
141 echo " --trace-syscalls=no|yes show all system calls? [no]"
142 echo " --trace-signals=no|yes show signal handling details? [no]"
143 echo " --trace-symtab=no|yes show symbol table details? [no]"
144 echo " --trace-malloc=no|yes show client malloc details? [no]"
145 echo " --stop-after=<number> switch to real CPU after executing"
146 echo " <number> basic blocks [infinity]"
147 echo " --dump-error=<number> show translation for basic block"
148 echo " associated with <number>'th"
149 echo " error context [0=don't show any]"
150 echo
151 echo " Extra options are read from env variable \$VALGRIND_OPTS"
152 echo
153 echo " Valgrind is Copyright (C) 2000-2002 Julian Seward"
154 echo " and licensed under the GNU General Public License, version 2."
155 echo " Bug reports, feedback, admiration, abuse, etc, to: $emailto."
156 echo
157 exit 1
158fi
159
160
161VG_ARGS="$VALGRIND_OPTS $vgsupp $vgopts"
162export VG_ARGS
163LD_PRELOAD=$VALGRIND/valgrind.so:$LD_PRELOAD
164export LD_PRELOAD
165exec $argopts
166
167