blob: 14c140963d3782eb2508108b3f19efc0e45e970a [file] [log] [blame]
#!/bin/sh
##--------------------------------------------------------------------##
##--- The startup script. valgrind ---##
##--------------------------------------------------------------------##
# This file is part of Valgrind, an extensible x86 protected-mode
# emulator for monitoring program execution on x86-Unixes.
#
# Copyright (C) 2002 Julian Seward
# jseward@acm.org
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
# 02111-1307, USA.
#
# The GNU General Public License is contained in the file COPYING.
# Should point to the installation directory
prefix="@prefix@"
exec_prefix="@exec_prefix@"
VALGRIND="@libdir@/valgrind"
# Other stuff ...
version="@VERSION@"
emailto="jseward@acm.org"
# The default name of the suppressions file
vgsupp="--suppressions=$VALGRIND/default.supp"
# Valgrind options
vgopts=
# --skin=<foo> arg, specifying skin used
skin_arg=
# Collect up args for Valgrind. Only --version and --skin are intercepted
# here; the rest are passed to vg_main.c.
while [ $# != 0 ]
do
arg=$1
case "$arg" in
--version) echo "valgrind-$version"; exit 1 ;;
--skin=*) skin_arg=$arg; shift;;
-*) vgopts="$vgopts $arg"; shift;;
*) break;;
esac
done
# Decide on the skin. Default to memory checking if not specified.
if [ z"$skin_arg" = z ]; then
skin=memcheck
else
# Hack off the "--skin=" prefix.
skin=`echo $skin_arg | sed 's/--skin=//'`
fi
# Setup skin shared object.
skin_so="vgskin_${skin}.so"
if [ ! -r $VALGRIND/$skin_so ] ; then
echo
echo "Skin error:"
echo " The shared library \`$skin_so' for the chosen"
echo " skin \`$skin' could not be found in"
echo " $VALGRIND"
echo
exit 1
fi
VG_ARGS="$VALGRIND_OPTS $vgsupp $vgopts"
export VG_ARGS
# A bit subtle. The LD_PRELOAD added entry must be absolute
# and not depend on LD_LIBRARY_PATH. This is so that we can
# mess with LD_LIBRARY_PATH for child processes, which makes
# libpthread.so fall out of visibility, independently of
# whether valgrind.so is visible.
LD_LIBRARY_PATH=$VALGRIND:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
# Insert skin .so before valgrind.so to override template functions.
LD_PRELOAD=$VALGRIND/$skin_so:$VALGRIND/valgrind.so:$LD_PRELOAD
export LD_PRELOAD
#LD_DEBUG=files
#LD_DEBUG=symbols
#export LD_DEBUG
# If no command given, act like -h was given so vg_main.c prints out
# the usage string. And pass to 'exec' tha name of any program -- it doesn't
# which -- because it won't be run anyway (we use 'true').
if [ $# != 0 ] ; then
exec "$@"
else
VG_ARGS="$VG_ARGS -h"
exec true
fi
##--------------------------------------------------------------------##
##--- end valgrind ---##
##--------------------------------------------------------------------##