Created
March 26, 2024 03:14
-
-
Save revsic/9bf950b0f74fe34639b43463fd68a56d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import os | |
import re | |
import subprocess | |
from tqdm import tqdm | |
_binary = "./build/bin/tiffinfo" | |
# _base = "./results/default/crashes" | |
# _dump = "./dump/default" | |
_base = "./results/crashes-jykim-4.0.4" | |
_dump = "./dump/crashes-jykim-4.0.4" | |
parsed = {} | |
os.makedirs(_dump, exist_ok=True) | |
for crash in tqdm(os.listdir(_base)): | |
p = subprocess.Popen( | |
[_binary, os.path.join(_base, crash)], | |
stdout=subprocess.PIPE, | |
stderr=subprocess.STDOUT, | |
universal_newlines=True, | |
) | |
outputs = "" | |
while p.poll() == None: | |
outputs += p.stdout.readline() | |
bugs = set(re.findall(r"AddressSanitizer\:\s+(.+?)\s+", outputs)) | |
fns = [ | |
f"{fn}: {_file}#L{_line}" | |
for _, fn, _file, _line in re.findall( | |
r"#\d+\s+(0x[a-f0-9]+)\s+in\s+(.+?)\s+.+/([a-zA-z0-9_]+\.c)\:(\d+)\:\d+", | |
outputs) | |
] | |
parsed[crash] = { | |
"bugs": list(bugs), | |
"fns": fns, | |
} | |
with open(f"{_dump}/{crash}.txt", "w") as f: | |
f.write(outputs) | |
with open(f"{_dump}.json", "w") as f: | |
json.dump(parsed, f, indent=4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment