11     mv = inf.read_memory (addr, 8)
 
   12     return mv.cast(
'L')[0]
 
   15     head = sheap_read_word (inf, addr+8)
 
   16     if head > 128*1024*1024 
or head < 8: 
return False 
   19     if head & 2: 
return False 
   20     foot = sheap_read_word (inf, addr+head)
 
   21     if head != foot: 
return False 
   22     nexthead = sheap_read_word (inf, addr+head+8)
 
   23     if nexthead & 1: 
return False 
   28     head = sheap_read_word (inf, addr+8)
 
   29     if head > 128*1024*1024 
or head < 8:
 
   34     nexthead = sheap_read_word (inf, addr+head+8)
 
   38         if not sheap_looks_free (inf, addr):
 
   42     s = f
'{int(addr):016x}:{type}{int(head):08x}\n' 
   44     return addr+head, 
True 
   47     inf = gdb.selected_inferior()
 
   48     addr1 = (addr1 + 7) & ~7 
 
   50         while addr1 < addr2 
and not sheap_looks_free (inf, addr1):
 
   53         addr1, ok = sheap_scan_2 (inf, addr1)
 
   60         addr1 = sheap_scan_1 (addr1, addr2, forced)
 
   69         raise gdb.GdbError (
'Missing start address')
 
   70     start_arg = gdb.parse_and_eval (args[0])
 
   71     end_arg = gdb.parse_and_eval (args[1]) 
if len(args) > 1 
else start_arg + 1024
 
   72     return sheap_scan (start_arg, end_arg, forced)
 
   76     """Dump out malloc heap in a range of addresses, showed allocated/free blocks. 
   78     sheap START-ADDR [END-ADDR] 
   79     will dump out free and allocated malloc blocks within the given address 
   80     range.  If not given, END-ADDR is taken to be 1024 bytes after START-ADDR. 
   82     Caveats: It is not possible to reliably identify allocated memory blocks. 
   83              Dumping will start at the first free block found within 
   84              the given range, if any. 
   86              This only works with the GNU libc malloc, not with any 
   87              alternative allocators (tcmalloc, etc). 
   90         super (SHeap, self).__init__ (
"sheap", gdb.COMMAND_DATA)
 
   94         return sheap (arg, 
False)