5
echo 'Usage: arb_valgrind [-m] [-c <callers>] [-f <filter>] [-l [-r]] [-A] <arb_program> <arguments>'
5
echo 'Usage: arb_valgrind [options] <arb_program> <arguments>'
7
7
echo ' runs valgrind (versions 3.x) on <arb_program> piping results through a filter'
8
8
echo ' so that the output can be used as emacs error messages'
10
12
echo ' -m use massif (default uses memcheck)'
11
13
echo ' -c <callers> show <callers> stackframes (default: none)'
12
14
echo ' [in fact they are always shown, but not marked as errors]'
13
15
echo ' -f <filter> regexpr to filter the reason (default: all)'
14
16
echo ' -l [-r] turn on leak-checking (-r for reachable blocks)'
15
17
echo ' -A show known boring errors (most Xt/Motif-related)'
19
echo ' -L <file> log stdout to <file> (does not work with -D)'
20
echo ' -E <file> log stderr to <file> (does not work with -D)'
21
echo ' Default is to collect output and print in after valgrind terminates'
16
22
echo ' -D run gdb on error'
23
echo ' -e return exitcode 1 on valgrind-errors'
19
26
echo 'Usage: arb_valgrind update'
68
79
while [ $SCAN_ARGS = 1 ] ; do
70
if [ $1 = '-m' ] ; then
81
if [ "$1" = "-m" ] ; then
71
82
TOOL='--tool=massif'
75
if [ $1 = '-c' ] ; then
86
if [ "$1" = "-c" ] ; then
80
if [ $1 = '-f' ] ; then
91
if [ "$1" = "-f" ] ; then
85
if [ $1 = '-l' ] ; then
86
LEAK_CHECK="$LEAK_CHECK --leak-check=yes --leak-resolution=high"
96
if [ "$1" = "-l" ] ; then
97
LEAK_CHECK="$LEAK_CHECK --leak-check=yes"
98
# LEAK_CHECK="$LEAK_CHECK --leak-resolution=high"
99
LEAK_CHECK="$LEAK_CHECK --leak-resolution=med"
90
if [ $1 = '-r' ] ; then
103
if [ "$1" = "-r" ] ; then
91
104
LEAK_CHECK="$LEAK_CHECK --show-reachable=yes"
95
if [ $1 = '-A' ] ; then
108
if [ "$1" = "-A" ] ; then
100
if [ $1 = '-D' ] ; then
113
if [ "$1" = "-q" ] ; then
118
if [ "$1" = "-D" ] ; then
101
119
ATTACH='--db-attach=yes'
123
if [ "$1" = "-L" ] ; then
128
if [ "$1" = "-E" ] ; then
133
if [ "$1" = "-e" ] ; then
134
ERROR_EXITCODE='--error-exitcode=123'
108
142
if [ "X$LEAK_CHECK" = "X" ] ; then
109
143
LEAK_CHECK="--leak-check=no"
123
158
if [ $RUN = 1 ] ; then
124
159
echo "Running valgrind on '$*' ..."
125
160
echo "CALLERS='$CALLERS'"
126
161
echo "FILTER ='$FILTER'"
127
162
VG_CALLERS=$[$CALLERS+5]
128
COMMAND="valgrind $TOOL -v --error-limit=no --num-callers=$VG_CALLERS $SHOW_REACHABLE $LEAK_CHECK $ATTACH $*"
129
echo "COMMAND='$COMMAND'"
164
VG_OPTS="$VG_OPTS --error-limit=yes"
165
VG_OPTS="$VG_OPTS $ERROR_EXITCODE"
166
# VG_OPTS="$VG_OPTS --track-origins=yes" # ulalala ... eats MUUUUCH memory
167
VG_OPTS="$VG_OPTS --track-fds=yes" # track filedescriptors open on exit
168
VG_OPTS="$VG_OPTS --show-below-main=yes" # valgrind below main (e.g. in static initialization)
169
VG_CMD="valgrind $QUIET $TOOL -v $VG_OPTS --num-callers=$VG_CALLERS $SHOW_REACHABLE $LEAK_CHECK $ATTACH"
170
echo "VG_CMD='$VG_CMD $@'"
130
171
if [ "$ATTACH" = "" ]; then
131
$COMMAND 2>&1 >/tmp/arb_valgrind_$USER.stdout | $DIR/valgrind2grep $CALLERS "$FILTER" $SUPPX
174
if [ -z "$LOG_STDOUT" ]; then
175
LOG_STDOUT=/tmp/arb_valgrind_$USER_$$.stdout
178
if [ -z "$LOG_STDERR" ]; then
179
LOG_STDERR=/tmp/arb_valgrind_$USER_$$.stderr
182
$VG_CMD --log-fd=3 "$@" 3>&1 >$LOG_STDOUT 2>$LOG_STDERR | $DIR/valgrind2grep $CALLERS "$FILTER" $SUPPX
183
EXITCODE=${PIPESTATUS[0]}
185
if [ "$POSTDUMP_STDOUT" = "1" ]; then
186
echo "-------------------- [stdout of '$@' ]"
190
if [ "$POSTDUMP_STDERR" = "1" ]; then
191
echo "-------------------- [stderr of '$@' ]"
195
if [ "$POSTDUMP_STDOUT" = "1" -o "$POSTDUMP_STDERR" = "1" ]; then
196
echo "-------------------- [end of output]"
135
echo 'valgrind done.'
202
echo "valgrind done (exitcode=$EXITCODE)"