Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add number arg for 'heap chunk' command #745

Merged
merged 5 commits into from Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/commands/heap.md
Expand Up @@ -60,6 +60,20 @@ Glibc's behavior. To be able to view unaligned chunks as well, you can disable
this with the `--allow-unaligned` flag. Note that this might result in
incorrect output.

To display heap chunk layout from address, simply provides the `number` argument after the `address` argument:
skysider marked this conversation as resolved.
Show resolved Hide resolved

```
gef➤ heap chunk [address] [number]
gef➤ heap chunk 0x4e5400 6
Chunk(addr=0x4e5400, size=0xd0, flags=PREV_INUSE)
Chunk(addr=0x4e54d0, size=0x1a0, flags=PREV_INUSE)
Chunk(addr=0x4e5670, size=0x200, flags=PREV_INUSE)
Chunk(addr=0x4e5870, size=0xbc0, flags=PREV_INUSE)
Chunk(addr=0x4e6430, size=0x330, flags=PREV_INUSE)
Chunk(addr=0x4e6760, size=0x4c0, flags=PREV_INUSE)

```

### `heap arenas` command ###

Multi-threaded programs have different arenas, and the knowledge of the
Expand Down
3 changes: 1 addition & 2 deletions gef.py
Expand Up @@ -7025,7 +7025,7 @@ def do_invoke(self, *args, **kwargs):
if number > 0:
addr = parse_address(args.address)
skysider marked this conversation as resolved.
Show resolved Hide resolved
current_chunk = GlibcChunk(addr, allow_unaligned=args.allow_unaligned)
while number:
for _ in range(number):
if current_chunk.size == 0:
break

Expand All @@ -7044,7 +7044,6 @@ def do_invoke(self, *args, **kwargs):
break

current_chunk = next_chunk
number -= 1

else:
addr = parse_address(args.address)
Expand Down