diff --git a/gdb/ghc_gdb/find_refs.py b/gdb/ghc_gdb/find_refs.py index 67d991ac35771178e6ba4a9f99387df22d141952..0d7c15509120af8353b928b3ad4d1eb0fa041412 100644 --- a/gdb/ghc_gdb/find_refs.py +++ b/gdb/ghc_gdb/find_refs.py @@ -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