-
Notifications
You must be signed in to change notification settings - Fork 8
/
trace-filter.py
28 lines (24 loc) · 1.02 KB
/
trace-filter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# This script will remove things from the input that make it harder to diff
# traces.
#
# To generate a trace, for instance run:
# PYPYLOG=jit-log-opt:List-new.log ./som-ast-jit -cp Smalltalk:Examples/Benchmarks/LanguageFeatures Examples/Benchmarks/BenchmarkHarness.som List 65 0 100
#
# Afterwards, the file can be filtered, for instance with:
# cat List-new.log | python trace-filter.py > List-new.log-filtered
#
import fileinput
import sys
import re
pointer = re.compile("0x[0-9a-f]{9,12}")
target_token = re.compile("TargetToken\\([0-9]*\\)")
address = re.compile("\\[[0-9a-f]{8,12}]")
line_num = re.compile("^\\+\\d*:")
long_number = re.compile("\\d{8,}")
for line in fileinput.input():
filtered_line = re.sub(pointer, '(ptr)', line)
filtered_line = re.sub(target_token, 'TargetToken(tkn)', filtered_line)
filtered_line = re.sub(address, '[adr]', filtered_line)
filtered_line = re.sub(line_num, '', filtered_line)
filtered_line = re.sub(long_number, '(num)', filtered_line)
sys.stdout.write(filtered_line)