pytracediff: change how 'junk' calls are handled
Instead of discarding them at parsing phase, let the difflib SequenceMatcher always ignore them, and optionally suppress them from output if -I/--ignore-junk option is given. Signed-off-by: Matti Hamalainen <ccr@tnsp.org> Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Reviewed-by: Dylan Baker <dylan@pnwbakers.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17135>
This commit is contained in:
parent
cf4d1c1fed
commit
95fc0e1b7c
|
@ -218,7 +218,7 @@ class TraceParser(XmlParser):
|
||||||
self.element_start('trace')
|
self.element_start('trace')
|
||||||
while self.token.type not in (ELEMENT_END, EOF):
|
while self.token.type not in (ELEMENT_END, EOF):
|
||||||
call = self.parse_call()
|
call = self.parse_call()
|
||||||
if not self.options.ignore_junk or not trace_call_ignore(call):
|
call.is_junk = trace_call_ignore(call)
|
||||||
self.handle_call(call)
|
self.handle_call(call)
|
||||||
if self.token.type != EOF:
|
if self.token.type != EOF:
|
||||||
self.element_end('trace')
|
self.element_end('trace')
|
||||||
|
@ -381,6 +381,9 @@ class SimpleTraceDumper(TraceParser):
|
||||||
self.pretty_printer = PrettyPrinter(self.formatter, options)
|
self.pretty_printer = PrettyPrinter(self.formatter, options)
|
||||||
|
|
||||||
def handle_call(self, call):
|
def handle_call(self, call):
|
||||||
|
if self.options.ignore_junk and call.is_junk:
|
||||||
|
return
|
||||||
|
|
||||||
call.visit(self.pretty_printer)
|
call.visit(self.pretty_printer)
|
||||||
|
|
||||||
|
|
||||||
|
@ -391,6 +394,9 @@ class TraceDumper(SimpleTraceDumper):
|
||||||
self.call_stack = []
|
self.call_stack = []
|
||||||
|
|
||||||
def handle_call(self, call):
|
def handle_call(self, call):
|
||||||
|
if self.options.ignore_junk and call.is_junk:
|
||||||
|
return
|
||||||
|
|
||||||
if self.options.named_ptrs:
|
if self.options.named_ptrs:
|
||||||
self.call_stack.append(call)
|
self.call_stack.append(call)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -319,7 +319,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
### Perform diffing
|
### Perform diffing
|
||||||
pkk_info("Matching trace sequences ...")
|
pkk_info("Matching trace sequences ...")
|
||||||
sequence = difflib.SequenceMatcher(None, stack1, stack2, autojunk=False)
|
sequence = difflib.SequenceMatcher(lambda x : x.is_junk, stack1, stack2, autojunk=False)
|
||||||
|
|
||||||
pkk_info("Sequencing diff ...")
|
pkk_info("Sequencing diff ...")
|
||||||
opcodes = sequence.get_opcodes()
|
opcodes = sequence.get_opcodes()
|
||||||
|
@ -378,18 +378,24 @@ if __name__ == "__main__":
|
||||||
while True:
|
while True:
|
||||||
# Get line data
|
# Get line data
|
||||||
if ncall1 < end1:
|
if ncall1 < end1:
|
||||||
|
if not options.ignore_junk or not stack1[ncall1].is_junk:
|
||||||
printer.entry_start(show_args)
|
printer.entry_start(show_args)
|
||||||
stack1[ncall1].visit(printer)
|
stack1[ncall1].visit(printer)
|
||||||
data1 = printer.entry_get()
|
data1 = printer.entry_get()
|
||||||
|
else:
|
||||||
|
data1 = []
|
||||||
ncall1 += 1
|
ncall1 += 1
|
||||||
else:
|
else:
|
||||||
data1 = []
|
data1 = []
|
||||||
last1 = True
|
last1 = True
|
||||||
|
|
||||||
if ncall2 < end2:
|
if ncall2 < end2:
|
||||||
|
if not options.ignore_junk or not stack2[ncall2].is_junk:
|
||||||
printer.entry_start(show_args)
|
printer.entry_start(show_args)
|
||||||
stack2[ncall2].visit(printer)
|
stack2[ncall2].visit(printer)
|
||||||
data2 = printer.entry_get()
|
data2 = printer.entry_get()
|
||||||
|
else:
|
||||||
|
data2 = []
|
||||||
ncall2 += 1
|
ncall2 += 1
|
||||||
else:
|
else:
|
||||||
data2 = []
|
data2 = []
|
||||||
|
|
Loading…
Reference in New Issue