mirror of
https://github.com/justinian/jsix.git
synced 2025-12-09 16:04:32 -08:00
[tools] Commit memory debug (et al) tooling
These are some changes I made to debug tooling while tracking down the bugfix in the previous commit. Each `scripts/debug_*_alloc.gdb` script has gdb output a `*_allocs.txt` file, which in turn can be parsed by the `scripts/parse_*_allocs.py` script to find errors.
This commit is contained in:
40
scripts/parse_frame_allocs.py
Executable file
40
scripts/parse_frame_allocs.py
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
def add_maps(allocs, addr, count):
|
||||
for i in range(count):
|
||||
if addr+i in allocs:
|
||||
print(f"ERROR: frame {addr+i:012x} map collision.")
|
||||
else:
|
||||
#print(f" frame {addr+i:012x} mapped")
|
||||
allocs.add(addr+i)
|
||||
|
||||
def remove_maps(allocs, addr, count):
|
||||
for i in range(count):
|
||||
if addr+i not in allocs:
|
||||
print(f" WARN: removing unmapped frame {addr+i:012x}")
|
||||
else:
|
||||
#print(f" frame {addr+i:012x} unmapped")
|
||||
allocs.remove(addr+i)
|
||||
|
||||
def parse_line(allocs, line):
|
||||
args = line.strip().split()
|
||||
match args:
|
||||
case ['+', addr, count]:
|
||||
add_maps(allocs, int(addr, base=16), int(count))
|
||||
case ['-', addr, count]:
|
||||
remove_maps(allocs, int(addr, base=16), int(count))
|
||||
case _:
|
||||
pass
|
||||
|
||||
def parse_file(f):
|
||||
allocs = set()
|
||||
for line in f.readlines():
|
||||
parse_line(allocs, line)
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
if len(sys.argv) > 1:
|
||||
with open(sys.argv[1]) as f:
|
||||
parse_file(f)
|
||||
else:
|
||||
parse_file(sys.stdin)
|
||||
Reference in New Issue
Block a user