2 Parses the id of the process that ran with ASAN from the output logs.
4 import sys
, argparse
, re
8 parser
= argparse
.ArgumentParser()
12 type=argparse
.FileType("r"),
14 help="The sanitizer output to get the pid from",
19 type=argparse
.FileType("r"),
21 help="Where to write the result",
23 args
= parser
.parse_args()
25 pid
= process_file(args
.infile
)
26 args
.outfile
.write(pid
)
31 def process_file(infile
):
32 # check first line is just ==== divider
33 first_line_pattern
= re
.compile(r
"=*")
34 assert first_line_pattern
.match(infile
.readline())
36 # parse out pid from 2nd line
37 # `==PID==ERROR: SanitizerName: error-type on address...`
38 pid_pattern
= re
.compile(r
"==([0-9]*)==ERROR:")
39 pid
= pid_pattern
.search(infile
.readline()).group(1)
43 assert pid
and pid
.isdigit()
48 if __name__
== "__main__":