Path: blob/21.2-virgl/src/gallium/tools/trace/tracediff.sh
4561 views
#!/usr/bin/env bash1##########################################################################2#3# Copyright 2011 Jose Fonseca4# All Rights Reserved.5#6# Permission is hereby granted, free of charge, to any person obtaining a copy7# of this software and associated documentation files (the "Software"), to deal8# in the Software without restriction, including without limitation the rights9# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell10# copies of the Software, and to permit persons to whom the Software is11# furnished to do so, subject to the following conditions:12#13# The above copyright notice and this permission notice shall be included in14# all copies or substantial portions of the Software.15#16# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR17# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,18# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE19# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER20# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,21# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN22# THE SOFTWARE.23#24##########################################################################/2526set -e2728PROGNAME="$(basename "$0")"29TRACEDUMP="${TRACEDUMP:-$(dirname "$0")/dump.py}"30313233###34### Helper functions35###36fatal()37{38echo "ERROR: $1"39exit 140}414243print_version()44{45echo "TraceDiff - Compare two Gallium trace files"46echo "(C) Copyright 2011 Jose Fonseca"47echo ""48}495051print_help()52{53echo "Usage: ${PROGNAME} [options] <tracefile1> <tracefile2>"54echo ""55echo " -h, --help display this help and exit"56echo " -V, --version output version information and exit"57echo ""58echo " -m, --meld use Meld for diffing (default is sdiff)"59echo ""60echo "dump.py options:"61echo " -N, --named generate symbolic names for raw pointer values"62echo " -M, --method-only output only call names without arguments"63echo ""64echo "sdiff options:"65echo " -d, --minimal try hard to find a smaller set of changes"66echo ""67}686970do_cleanup()71{72if test -d "$TEMPDIR"; then73rm -rf "$TEMPDIR"74fi75}767778strip_dump()79{80INFILE="$1"81OUTFILE="$2"8283python3 "$TRACEDUMP" --plain --suppress \84"${DUMP_ARGS[@]}" "$INFILE" \85| sed \86-e '/pipe_screen::is_format_supported/d' \87-e '/pipe_screen::get_\(shader_\)\?paramf\?/d' \88-e 's/\r$//g' \89-e 's/, /,\n\t/g' \90-e 's/) = /)\n\t= /' \91> "$OUTFILE"92}939495###96### Main code starts97###98trap do_cleanup HUP INT TERM99DUMP_ARGS=()100SDIFF_ARGS=()101USE_MELD=0102103while test -n "$1"104do105case "$1" in106--version|-V)107print_version108exit 0109;;110--help|-h)111print_version112print_help113exit 0114;;115-N|--named|-M|--method-only)116DUMP_ARGS+=("$1")117shift118;;119-d|--minimal)120SDIFF_ARGS+=("$1")121shift122;;123-m|--meld)124USE_MELD=1125shift126;;127*)128if test "x$INFILE1" = "x"; then129INFILE1="$1";130elif test "x$INFILE2" = "x"; then131INFILE2="$1";132else133fatal "Too many input filenames specified."134fi135shift136;;137esac138done139140141if test "x$INFILE1" = "x" -o "x$INFILE2" = "x"; then142print_help143fatal "Not enough input file(s) specified!"144fi145146147TEMPDIR="$(mktemp -d)"148TEMP1="${TEMPDIR}/1"149TEMP2="${TEMPDIR}/2"150151if test $USE_MELD -ne 0; then152strip_dump "$INFILE1" "$TEMP1" "$@" || fatal "Could not dump '${INFILE1}."153strip_dump "$INFILE2" "$TEMP2" "$@" || fatal "Could not dump '${INFILE2}."154meld "$TEMP1" "$TEMP2"155else156mkfifo "$TEMP1" || fatal "Could not create fifo 1"157mkfifo "$TEMP2" || fatal "Could not create fifo 2"158159strip_dump "$INFILE1" "$TEMP1" "$@" &160strip_dump "$INFILE2" "$TEMP2" "$@" &161162sdiff \163--left-column \164--width="$(tput cols)" \165--speed-large-files \166"${SDIFF_ARGS[@]}" \167"$TEMP1" "$TEMP2" \168| less169fi170171172