mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2025-12-24 16:00:11 +01:00
Use lookup_symbol() on the return address to identify the caller and emit useful debug info to the trace.
98 lines
1.8 KiB
Bash
98 lines
1.8 KiB
Bash
#!/bin/sh
|
|
|
|
prefix=@prefix@
|
|
exec_prefix=@exec_prefix@
|
|
|
|
nofile=
|
|
verbose=
|
|
flush=
|
|
nocallers=
|
|
|
|
usage() {
|
|
cat << EOF
|
|
usage: cairo-trace [--no-file|--verbose] 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.
|
|
--verbose - Show the trace on stdout.
|
|
--no-file - Disable the creation of an output file.
|
|
--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
|
|
--verbose)
|
|
skip=1
|
|
verbose=1
|
|
;;
|
|
--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 $*
|
|
|
|
filename=""
|
|
if test -z "$nofile"; then
|
|
filename=`basename -- $1`.$$.trace
|
|
fi
|
|
|
|
LD_PRELOAD=@libdir@/cairo/cairo-trace.so
|
|
export LD_PRELOAD
|
|
|
|
# Force the decimal output to the 'C' locale
|
|
LC_ALL=C
|
|
export LC_ALL
|
|
|
|
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 "$filename"; then
|
|
CAIRO_TRACE_FD=3 $* 3>&1 >/dev/null
|
|
elif test -z "$verbose"; then
|
|
echo "Recording trace in $filename."
|
|
CAIRO_TRACE_OUTFILE_EXACT=$filename $*
|
|
else
|
|
CAIRO_TRACE_FD=3 $* 3>&1 >/dev/null | tee $filename
|
|
fi
|