blob: b316a74ea1afb17b16d2c1f514c51de573278bf5 [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
sewardj557fb852002-04-22 22:26:51 +000032while [ $+ != 0 ]
sewardjde4a1d02002-03-22 01:27:54 +000033do
sewardj557fb852002-04-22 22:26:51 +000034 arg=$1
sewardjde4a1d02002-03-22 01:27:54 +000035 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;;
sewardj97ced732002-03-25 00:07:36 +000044 --check-addrVs=no) vgopts="$vgopts $arg"; shift;;
45 --check-addrVs=yes) vgopts="$vgopts $arg"; shift;;
sewardjde4a1d02002-03-22 01:27:54 +000046 --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;;
njn4f9c9342002-04-29 16:03:24 +000068 --cachesim=yes) vgopts="$vgopts $arg"; shift;;
69 --cachesim=no) vgopts="$vgopts $arg"; shift;;
sewardj8d365b52002-05-12 10:52:16 +000070 --weird-hacks=*) vgopts="$vgopts $arg"; shift;;
sewardjde4a1d02002-03-22 01:27:54 +000071# 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;;
sewardjde4a1d02002-03-22 01:27:54 +000081 --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;;
sewardj8937c812002-04-12 20:12:20 +000092 --trace-sched=yes) vgopts="$vgopts $arg"; shift;;
93 --trace-sched=no) vgopts="$vgopts $arg"; shift;;
sewardj45b4b372002-04-16 22:50:32 +000094 --trace-pthread=none) vgopts="$vgopts $arg"; shift;;
95 --trace-pthread=some) vgopts="$vgopts $arg"; shift;;
96 --trace-pthread=all) vgopts="$vgopts $arg"; shift;;
sewardjde4a1d02002-03-22 01:27:54 +000097 --stop-after=*) vgopts="$vgopts $arg"; shift;;
98 --dump-error=*) vgopts="$vgopts $arg"; shift;;
99 -*) dousage=1; break;;
100 *) break;;
101 esac
102done
103
sewardjde4a1d02002-03-22 01:27:54 +0000104if [ z"$doversion" = z1 ]; then
105 echo "valgrind-$version"
106 exit 1
107fi
108
sewardj557fb852002-04-22 22:26:51 +0000109if [ $# = 0 ] || [ z"$dousage" = z1 ]; then
sewardjde4a1d02002-03-22 01:27:54 +0000110 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>"
sewardj97ced732002-03-25 00:07:36 +0000133 echo " --check-addrVs=no|yes experimental lighterweight checking? [yes]"
134 echo " yes == Valgrind's original behaviour"
njn4f9c9342002-04-29 16:03:24 +0000135 echo " --cachesim=no|yes do cache profiling? [no]"
sewardj8d365b52002-05-12 10:52:16 +0000136 echo " --weird-hacks=hack1,hack2,... [no hacks selected]"
sewardj3984b852002-05-12 03:00:17 +0000137 echo " recognised hacks are: ioctl-VTIME"
138 echo ""
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
sewardj3e1eb1f2002-05-18 13:14:17 +0000168# A bit subtle. The LD_PRELOAD added entry must be absolute
169# and not depend on LD_LIBRARY_PATH. This is so that we can
170# mess with LD_LIBRARY_PATH for child processes, which makes
171# libpthread.so fall out of visibility, independently of
172# whether valgrind.so is visible.
sewardjde4a1d02002-03-22 01:27:54 +0000173
174VG_ARGS="$VALGRIND_OPTS $vgsupp $vgopts"
175export VG_ARGS
sewardj2e93c502002-04-12 11:12:52 +0000176LD_LIBRARY_PATH=$VALGRIND:$LD_LIBRARY_PATH
177export LD_LIBRARY_PATH
sewardj3e1eb1f2002-05-18 13:14:17 +0000178LD_PRELOAD=$VALGRIND/valgrind.so:$LD_PRELOAD
sewardjde4a1d02002-03-22 01:27:54 +0000179export LD_PRELOAD
sewardj2e93c502002-04-12 11:12:52 +0000180#LD_DEBUG=files
sewardj5716dbb2002-04-26 03:28:18 +0000181#LD_DEBUG=symbols
sewardj2e93c502002-04-12 11:12:52 +0000182#export LD_DEBUG
sewardj557fb852002-04-22 22:26:51 +0000183exec "$@"