vmmap ¤
Routines to enumerate mapped memory, and attempt to associate address ranges with various ELF files and permissions.
The reason that we need robustness is that not every operating system has /proc/$$/maps, which backs 'info proc mapping'.
Functions:
-
is_corefile–For example output use:
-
get_known_maps–Similar to
vmmap.get(), except only returns maps in cases where -
iter_coredump_sections– -
enhance_coredump_sections_pages_info– -
enhance_known_pages_info– -
coredump_maps–Parses
info proc mappingsandmaintenance info sections -
parse_info_proc_mappings_line–Parse a line from
info proc mappingsand return a pwndbg.lib.memory.Page -
info_proc_maps–Parse the result of info proc mappings.
-
proc_tid_maps–Parse the contents of /proc/$TID/maps on the server.
is_corefile ¤
For example output use
gdb ./tests/binaries/crash_simple.out -ex run -ex 'generate-core-file ./core' -ex 'quit'
And then use
gdb ./tests/binaries/crash_simple.out -core ./core -ex 'info target'
And: gdb -core ./core
As the two differ in output slighty.
get_known_maps ¤
get_known_maps() -> tuple[Page, ...] | None
Similar to vmmap.get(), except only returns maps in cases where the mappings are known, like if it's a coredump, or if process mappings are available.
enhance_coredump_sections_pages_info ¤
enhance_coredump_sections_pages_info(pages: list[Page]) -> None
coredump_maps ¤
coredump_maps() -> tuple[Page, ...]
Parses info proc mappings and maintenance info sections and tries to make sense out of the result :)
parse_info_proc_mappings_line ¤
parse_info_proc_mappings_line(
line: str, perms_available: bool, parse_flags: bool
) -> Page | None
Parse a line from info proc mappings and return a pwndbg.lib.memory.Page object if the line is valid.
Example lines
0x4c3000 0x4c5000 0x2000 0xc2000 rw-p /root/hello_world/main 0x4c5000 0x4cb000 0x6000 0x0 rw-p
The objfile column might be empty, and the permissions column is only present in GDB versions >= 12.1 bminor/binutils-gdb@29ef4c0
Parameters:
-
line(str) –A line from
info proc mappings.
Returns:
-
Page | None–A pwndbg.lib.memory.Page object or None.
info_proc_maps ¤
info_proc_maps(parse_flags: bool = True) -> tuple[Page, ...]
Parse the result of info proc mappings.
Example output:
Start Addr End Addr Size Offset Perms objfile
0x400000 0x401000 0x1000 0x0 r--p /root/hello_world/main
0x401000 0x497000 0x96000 0x1000 r-xp /root/hello_world/main
0x497000 0x4be000 0x27000 0x97000 r--p /root/hello_world/main
0x4be000 0x4c3000 0x5000 0xbd000 r--p /root/hello_world/main
0x4c3000 0x4c5000 0x2000 0xc2000 rw-p /root/hello_world/main
0x4c5000 0x4cb000 0x6000 0x0 rw-p
0x4cb000 0x4ed000 0x22000 0x0 rw-p [heap]
0x7ffff7ff9000 0x7ffff7ffd000 0x4000 0x0 r--p [vvar]
0x7ffff7ffd000 0x7ffff7fff000 0x2000 0x0 r-xp [vdso]
0x7ffffffde000 0x7ffffffff000 0x21000 0x0 rw-p [stack]
0xffffffffff600000 0xffffffffff601000 0x1000 0x0 --xp [vsyscall]
Note: this may return no pages due to a bug/behavior of GDB. See https://sourceware.org/bugzilla/show_bug.cgi?id=31207 for more information.
Returns:
-
Page–A tuple of pwndbg.lib.memory.Page objects or an empty tuple if
-
...–info proc mapping is not supported on the target.