blob: d386912cf25dc6bf1d3e35e61ae1878eb041232a [file] [log] [blame]
Brian Paul65ced472006-06-02 14:50:28 +00001#!/bin/bash
2
3# Copyright (C) 2006 Thomas Sondergaard
4# All Rights Reserved.
5#
6# Permission is hereby granted, free of charge, to any person obtaining a
7# copy of this software and associated documentation files (the "Software"),
8# to deal in the Software without restriction, including without limitation
9# on the rights to use, copy, modify, merge, publish, distribute, sub
10# license, and/or sell copies of the Software, and to permit persons to whom
11# the Software is furnished to do so, subject to the following conditions:
12#
13# The above copyright notice and this permission notice (including the next
14# paragraph) shall be included in all copies or substantial portions of the
15# Software.
16#
17# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
20# IBM AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23# IN THE SOFTWARE.
24#
25# Authors:
26# Thomas Sondergaard <ts@medical-insight.com>
27
28usage="usage: $0 [ -hctev ] [-l LOGFILE] program [args...]\n\t-h\t\thelp (this text)\n\t-c\t\tlog gl calls\n\t-t\t\ttime stamp log entries\n\t-e\t\tcheck for and log errors. errors occurring between\n\t\t\tglBegin() and glEnd() are checked at glEnd()\n\t-v\t\tverbose. Shows configuration settings passed to\n\t\t\tgltrace.so\n\t-l LOGFILE\tlogfile. Default is stderr"
29
30# Path to gltrace.so - must not be relative
31#GLTRACE_SO=/home/ts/Mesa_gltrace/src/mesa/glapi/gltrace.so
32# This seems to work:
33GLTRACE_SO=./gltrace.so
34
35# Set options from command line
36
37VERBOSE=0
38GLTRACE_LOG_CALLS=0
39GLTRACE_LOG_TIME=0
40GLTRACE_CHECK_ERRORS=0
41export GLTRACE_LOG_CALLS GLTRACE_LOG_TIME GLTRACE_CHECK_ERRORS
42
43if [ $# -eq 0 ]; then
44 echo -e $usage
45 exit
46fi
47
48while getopts "hctevl:" options; do
49 case $options in
50 h) echo -e $usage
51 exit 1;;
52 c) GLTRACE_LOG_CALLS=1;;
53 t) GLTRACE_LOG_TIME=1;;
54 e) GLTRACE_CHECK_ERRORS=1;;
55 l) GLTRACE_LOGFILE=$OPTARG
56 export GLTRACE_LOGFILE;;
57 v) VERBOSE=1;;
58 *) echo -e $usage
59 exit 1;;
60 esac
61done
62
63# Remove the parsed args
64shift $(($OPTIND-1))
65
66if [ ! -r $GLTRACE_SO ]; then
67 echo "Error: The gltrace.so file '$GLTRACE_SO' is missing!"
68 exit 1
69fi
70
71export LD_PRELOAD=$GLTRACE_SO
72
73if [ $VERBOSE -eq 1 ]; then
74 echo GLTRACE_LOG_CALLS=$GLTRACE_LOG_CALLS
75 echo GLTRACE_LOG_TIME=$GLTRACE_LOG_TIME
76 echo GLTRACE_CHECK_ERRORS=$GLTRACE_CHECK_ERRORS
77 echo GLTRACE_LOGFILE=$GLTRACE_LOGFILE
78 echo LD_PRELOAD=$LD_PRELOAD
79 echo command=$*
80fi
81
82exec $*