(addr=None, verbose=False, simple=False)
Iteratively print chunks on a heap, default to the current thread's
    active heap.
Iteratively print chunks on a heap, default to the current thread's
    active heap.
Iteratively print chunks on a heap default to the current thread s active heap .
def heap(addr=None, verbose=False, simple=False):
    """Iteratively print chunks on a heap, default to the current thread's
    active heap.
    """
    allocator = pwndbg.heap.current
    heap_region = allocator.get_heap_boundaries(addr)
    arena = allocator.get_arena_for_chunk(addr) if addr else allocator.get_arena()
    top_chunk = arena['top']
    ptr_size = allocator.size_sz

    # Calculate where to start printing; if an address was supplied, use that,
    # if this heap belongs to the main arena, start at the beginning of the
    # heap's mapping, otherwise, compensate for the presence of a heap_info
    # struct and possibly an arena.
    if addr:
        cursor = int(addr)
    elif arena == allocator.main_arena:
        cursor = heap_region.start
    else:
        cursor = heap_region.start + allocator.heap_info.sizeof
        if pwndbg.vmmap.find(allocator.get_heap(heap_region.start)['ar_ptr']) == heap_region:
            # Round up to a 2-machine-word alignment after an arena to
            # compensate for the presence of the have_fastchunks variable
            # in GLIBC versions >= 2.27.
            cursor += (allocator.malloc_state.sizeof + ptr_size) & ~allocator.malloc_align_mask

    # i686 alignment heuristic
    first_chunk_size = pwndbg.arch.unpack(pwndbg.memory.read(cursor + ptr_size, ptr_size))
    if first_chunk_size == 0:
        cursor += ptr_size * 2

    while cursor in heap_region:
        malloc_chunk(cursor, verbose=verbose, simple=simple)

        if cursor == top_chunk:
            break

        size_field = pwndbg.memory.u(cursor + allocator.chunk_key_offset('size'))
        real_size = size_field & ~allocator.malloc_align_mask
        cursor += real_size

        # Avoid an infinite loop when a chunk's size is 0.
        if real_size == 0:
            break
def heap ( addr = None , verbose = False , simple = False ) : allocator = pwndbg . heap . current heap_region = allocator . get_heap_boundaries ( addr ) arena = allocator . get_arena_for_chunk ( addr ) if addr else allocator . get_arena ( ) top_chunk = arena [ 'top' ] ptr_size = allocator . size_sz # Calculate where to start printing; if an address was supplied, use that, # if this heap belongs to the main arena, start at the beginning of the # heap's mapping, otherwise, compensate for the presence of a heap_info # struct and possibly an arena. if addr : cursor = int ( addr ) elif arena == allocator . main_arena : cursor = heap_region . start else : cursor = heap_region . start + allocator . heap_info . sizeof if pwndbg . vmmap . find ( allocator . get_heap ( heap_region . start ) [ 'ar_ptr' ] ) == heap_region : # Round up to a 2-machine-word alignment after an arena to # compensate for the presence of the have_fastchunks variable # in GLIBC versions >= 2.27. cursor += ( allocator . malloc_state . sizeof + ptr_size ) & ~ allocator . malloc_align_mask # i686 alignment heuristic first_chunk_size = pwndbg . arch . unpack ( pwndbg . memory . read ( cursor + ptr_size , ptr_size ) ) if first_chunk_size == 0 : cursor += ptr_size * 2 while cursor in heap_region : malloc_chunk ( cursor , verbose = verbose , simple = simple ) if cursor == top_chunk : break size_field = pwndbg . memory . u ( cursor + allocator . chunk_key_offset ( 'size' ) ) real_size = size_field & ~ allocator . malloc_align_mask cursor += real_size # Avoid an infinite loop when a chunk's size is 0. if real_size == 0 : break