mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2025-12-25 08:20:10 +01:00
This interferes with the application being traced. It is not clear from printf(3) whether "%.f" is locale dependent or not - but until we have a failure do not break applications unnecessarily!
81 lines
1.5 KiB
Bash
81 lines
1.5 KiB
Bash
#!/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
|