Skip to content

Instantly share code, notes, and snippets.

@redthing1
Forked from SiD3W4y/covdiff.py
Created September 2, 2024 21:17
Show Gist options
  • Save redthing1/eb16a042842e880d0c41cbb19819bab3 to your computer and use it in GitHub Desktop.
Save redthing1/eb16a042842e880d0c41cbb19819bab3 to your computer and use it in GitHub Desktop.
Script diffing two sets of GBA basic block traces
import sys
def getvals(path):
lines = open(path, "r").readlines()
lst = []
for line in lines:
line = line.strip()
if len(line) >= 10:
addr, cnt = line.split(" ")
lst.append((int(addr, 16), int(cnt)))
resmap = {}
resset = set()
for addr, cnt in lst:
resmap[addr] = cnt
resset.add(addr)
return resset, resmap
if __name__ == '__main__':
if len(sys.argv) < 3:
print("covdiff.py <before.cov...> <after.cov>")
else:
diffset, diffmap = getvals(sys.argv[-1])
for e in sys.argv[1:-1]:
eset, emap = getvals(e)
diffset = diffset - eset
for e in diffset:
print("0x{:08x} {}".format(e, diffmap[e]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment