Commit fe2a2b57 authored by Ben Gamari's avatar Ben Gamari 🐢

gdb.find_refs: Things

parent af398a35
......@@ -14,6 +14,8 @@ T = TypeVar('T')
stg_STACK_info = gdb.parse_and_eval('&stg_STACK_info')
CLOSURE_HEADER_SIZE = gdb.parse_and_eval('sizeof(StgHeader)') # bytes
def search_memory_many(inferior: gdb.Inferior, start: Ptr, end: Ptr, val: bytes) -> Iterator[Ptr]:
#print('Searching for %r in %d to %d' % (val, start.addr(), end.addr()))
assert end.addr() > start.addr()
......@@ -167,7 +169,7 @@ def find_containing_closure(inferior: gdb.Inferior,
if ptr.addr() - start.addr() > 8:
# Only trace the indirectee of IND_STATICs
return None
elif i <= nptrs + 5: # A bit of fudge for the headers
elif i <= nptrs + CLOSURE_HEADER_SIZE: # A bit of fudge for the headers
return start
elif int(info['type']) == closure.ClosureType.STACK:
stack = gdb.parse_and_eval('(StgStack *) %d' % start.addr())
......@@ -182,8 +184,7 @@ def find_containing_closure(inferior: gdb.Inferior,
except gdb.MemoryError as e:
print('failed to find containing closure of 0x%x:' % ptr.addr())
traceback.print_exc()
continue
return None
return None
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment