Debian Codegraph @

rpython/translator/revdb/pplog.py

raw symbols SCIP
1 #!/usr/bin/env pypy
2
3 # Post-process log files to make them diff-able.
4 #
5 # When you get errors caused by revdb.py getting out of sync with the
6 # original log file, recompile the program (e.g. pypy-c) by editing
7 # revdb_include.h, enabling the "#if 0" (at least the first one,
8 # possibly the second one too). This prints locations to stderr of
9 # all the EMITs. Then create the log file by redirecting stderr to
10 # "log.err1", and then run revdb.py by redirecting stderr to
11 # "log.err2" (typically, entering the "c" command to continue to the
12 # end). Then diff them both after applying this filter:
13 #
14 # diff -u <(cat log.err1 | .../rpython/translator/revdb/pplog.py) \
15 # <(cat log.err2 | .../rpython/translator/revdb/pplog.py) | less
16
17
18 import sys, re
19
20 r_hide_tail = re.compile(r"revdb[.]c:\d+: ([0-9a-f]+)")
21
22 r_remove = re.compile(r"\w+[.]c:\d+: obj 92233720368|"
23 r"PID \d+ starting, log file disabled|"
24 r"\[")
25
26
27 def post_process(fin, fout):
28 for line in fin:
29 match = r_hide_tail.match(line)
30 if match:
31 line = 'revdb.c:after pplog.py: %s\n' % ('#' * len(match.group(1)),)
32 elif r_remove.match(line):
33 continue
34 fout.write(line)
35
36
37 if __name__ == '__main__':
38 post_process(sys.stdin, sys.stdout)