cairo/util/cairo-trace/cairo-trace.in

82 lines
1.5 KiB
Text
Raw Normal View History

#!/bin/sh
prefix=@prefix@
exec_prefix=@exec_prefix@
nofile=
flush=
nocallers=
usage() {
cat << EOF
usage: cairo-trace [--no-file] command
cairo-trace will generate a log of all calls made by command to
cairo. This log will be stored in a file in the local directory
called command.pid.trace.
Whatever else happens is driven by its argument:
--flush - Flush the output trace after every call.
--no-file - Disable the creation of an output file. Outputs to the
terminal instead.
--no-callers - Do not lookup the caller address/symbol/line whilst tracing.
Enviroment variables understood by cairo-trace:
CAIRO_TRACE_FLUSH - flush the output after every function call.
CAIRO_TRACE_LINE_INFO - emit line information for most function calls.
EOF
exit
}
skip=1
while test $skip -eq 1; do
skip=0
case $1 in
--flush)
skip=1
flush=1
;;
--no-file)
skip=1
nofile=1
;;
--no-callers)
skip=1
nocallers=1
;;
--version)
echo "cairo-trace, version @CAIRO_VERSION_MAJOR@.@CAIRO_VERSION_MINOR@.@CAIRO_VERSION_MICRO@."
exit
;;
--help)
usage
;;
esac
if test $skip -eq 1; then
shift
fi
done
if test $# -eq 0; then
usage
fi
#echo $*
LD_PRELOAD=@libdir@/cairo/cairo-trace.so
export LD_PRELOAD
if test -n "$nocallers"; then
CAIRO_TRACE_LINE_INFO=0
export CAIRO_TRACE_LINE_INFO
fi
if test -n "$flush"; then
CAIRO_TRACE_FLUSH=1
export CAIRO_TRACE_FLUSH
fi
if test -z "$nofile"; then
CAIRO_TRACE_OUTDIR=. "$@"
else
CAIRO_TRACE_FD=3 "$@" 3>&1 >/dev/null
fi