From 054b2afcb9344cab346c8d53ae8909f1acd07319 Mon Sep 17 00:00:00 2001 From: Matti Hamalainen Date: Tue, 20 Apr 2021 15:24:42 +0300 Subject: [PATCH] gallium/tools: implement better suppression of variants Previously some variants (such as execution time and call number were suppressed in tracediff.sh via a sed script. It makes sense to implement an option to leave out such variants to begin with in dump.py, so let's do so and use it. Signed-off-by: Matti Hamalainen Acked-By: Mike Blumenkrantz Part-of: --- src/gallium/tools/trace/model.py | 11 +++++++---- src/gallium/tools/trace/parse.py | 5 ++++- src/gallium/tools/trace/tracediff.sh | 4 +--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/gallium/tools/trace/model.py b/src/gallium/tools/trace/model.py index 1cd3c18d987..fad3241a7d7 100755 --- a/src/gallium/tools/trace/model.py +++ b/src/gallium/tools/trace/model.py @@ -45,7 +45,7 @@ class Node: def __str__(self): stream = StringIO() formatter = format.Formatter(stream) - pretty_printer = PrettyPrinter(formatter) + pretty_printer = PrettyPrinter(formatter, {}) self.visit(pretty_printer) return stream.getvalue() @@ -164,9 +164,11 @@ class Visitor: class PrettyPrinter: - def __init__(self, formatter): + def __init__(self, formatter, options): self.formatter = formatter + self.options = options + def visit_literal(self, node): if node.value is None: self.formatter.literal('NULL') @@ -208,7 +210,8 @@ class PrettyPrinter: self.formatter.address(node.address) def visit_call(self, node): - self.formatter.text('%s ' % node.no) + if not self.options.suppress_variants: + self.formatter.text('%s ' % node.no) if node.klass is not None: self.formatter.function(node.klass + '::' + node.method) else: @@ -225,7 +228,7 @@ class PrettyPrinter: if node.ret is not None: self.formatter.text(' = ') node.ret.visit(self) - if node.time is not None: + if not self.options.suppress_variants and node.time is not None: self.formatter.text(' // time ') node.time.visit(self) diff --git a/src/gallium/tools/trace/parse.py b/src/gallium/tools/trace/parse.py index d25b0b258c6..31e6b51668e 100755 --- a/src/gallium/tools/trace/parse.py +++ b/src/gallium/tools/trace/parse.py @@ -359,7 +359,7 @@ class TraceDumper(TraceParser): self.formatter = format.Formatter(outStream) else: self.formatter = format.DefaultFormatter(outStream) - self.pretty_printer = PrettyPrinter(self.formatter) + self.pretty_printer = PrettyPrinter(self.formatter, options) def handle_call(self, call): call.visit(self.pretty_printer) @@ -400,6 +400,9 @@ class Main: optparser.add_argument("-p", "--plain", action="store_const", const=True, default=False, dest="plain", help="disable ANSI color etc. formatting") + optparser.add_argument("-S", "--suppress", + action="store_const", const=True, default=False, + dest="suppress_variants", help="suppress some variants in output for better diffability") return optparser def process_arg(self, stream, options): diff --git a/src/gallium/tools/trace/tracediff.sh b/src/gallium/tools/trace/tracediff.sh index be3dba331dd..95ab50d7584 100755 --- a/src/gallium/tools/trace/tracediff.sh +++ b/src/gallium/tools/trace/tracediff.sh @@ -49,13 +49,11 @@ strip_dump() OUTFILE="$1" shift - python3 "$TRACEDUMP" --plain "$@" "$INFILE" \ + python3 "$TRACEDUMP" --plain --suppress "$@" "$INFILE" \ | sed \ - -e 's@ // time .*@@' \ -e '/pipe_screen::is_format_supported/d' \ -e '/pipe_screen::get_\(shader_\)\?paramf\?/d' \ -e 's/\r$//g' \ - -e 's/^[0-9]\+ //' \ -e 's/pipe = \w\+/pipe/g' \ -e 's/screen = \w\+/screen/g' \ -e 's/, /,\n\t/g' \