diff options
author | Matti Hamalainen <ccr@tnsp.org> | 2021-04-20 15:15:59 +0300 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2021-05-07 15:48:03 +0000 |
commit | 0834a42773fa234f00b87151473a7b086c31e066 (patch) | |
tree | 84727768a3640f45de539a3ac9f1c5f9aaea0786 /src/gallium/tools/trace | |
parent | a6765412fe1609ab3cc3829e0f9b13d6f63aaceb (diff) |
gallium/tools: improve option handling in dump_state.py
Previously we inherited some options from parse.py, but
that made no sense for some of the options that are not
needed for dump_state.py (such as --plain, as we output
only JSON format text.)
So, remove the inherit and implement filename argument
here independantly.
Signed-off-by: Matti Hamalainen <ccr@tnsp.org>
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10648>
Diffstat (limited to 'src/gallium/tools/trace')
-rwxr-xr-x | src/gallium/tools/trace/dump_state.py | 12 | ||||
-rwxr-xr-x | src/gallium/tools/trace/model.py | 4 | ||||
-rwxr-xr-x | src/gallium/tools/trace/parse.py | 2 |
3 files changed, 11 insertions, 7 deletions
diff --git a/src/gallium/tools/trace/dump_state.py b/src/gallium/tools/trace/dump_state.py index 8b68d83f9a2..b23a929e265 100755 --- a/src/gallium/tools/trace/dump_state.py +++ b/src/gallium/tools/trace/dump_state.py @@ -33,6 +33,7 @@ import json import binascii import re import copy +import argparse import model import parse as parser @@ -705,7 +706,7 @@ class Context(Dispatcher): return so_target -class Interpreter(parser.TraceDumper): +class Interpreter(parser.TraceParser): '''Specialization of a trace parser that interprets the calls as it goes along.''' @@ -722,7 +723,7 @@ class Interpreter(parser.TraceDumper): )) def __init__(self, stream, options): - parser.TraceDumper.__init__(self, stream, options, sys.stderr) + parser.TraceParser.__init__(self, stream) self.options = options self.objects = {} self.result = None @@ -791,9 +792,12 @@ class Interpreter(parser.TraceDumper): class Main(parser.Main): def get_optparser(self): - '''Custom options.''' + optparser = argparse.ArgumentParser( + description="Parse and dump Gallium trace(s) as JSON") + + optparser.add_argument("filename", action="extend", nargs="+", + type=str, metavar="filename", help="Gallium trace filename (plain or .gz, .bz2)") - optparser = parser.Main.get_optparser(self) optparser.add_argument("-v", "--verbose", action="count", default=0, dest="verbosity", help="increase verbosity level") optparser.add_argument("-q", "--quiet", action="store_const", const=0, dest="verbosity", help="no messages") optparser.add_argument("-c", "--call", action="store", type=int, dest="call", default=0xffffffff, help="dump on this call") diff --git a/src/gallium/tools/trace/model.py b/src/gallium/tools/trace/model.py index 913a4ef13d2..1cd3c18d987 100755 --- a/src/gallium/tools/trace/model.py +++ b/src/gallium/tools/trace/model.py @@ -44,7 +44,7 @@ class Node: def __str__(self): stream = StringIO() - formatter = format.DefaultFormatter(stream) + formatter = format.Formatter(stream) pretty_printer = PrettyPrinter(formatter) self.visit(pretty_printer) return stream.getvalue() @@ -206,7 +206,7 @@ class PrettyPrinter: def visit_pointer(self, node): self.formatter.address(node.address) - + def visit_call(self, node): self.formatter.text('%s ' % node.no) if node.klass is not None: diff --git a/src/gallium/tools/trace/parse.py b/src/gallium/tools/trace/parse.py index a529f389723..d25b0b258c6 100755 --- a/src/gallium/tools/trace/parse.py +++ b/src/gallium/tools/trace/parse.py @@ -355,7 +355,7 @@ class TraceDumper(TraceParser): def __init__(self, fp, options, outStream = sys.stdout): TraceParser.__init__(self, fp) - if options.plain: + if "plain" in options and options.plain: self.formatter = format.Formatter(outStream) else: self.formatter = format.DefaultFormatter(outStream) |