mirror of https://github.com/pwndbg/pwndbg
Add a header to the vmmap table (#1311)
* Add a header to the vmmap table A simple header has been added to the output of vmmap which helps new users identify the columns. * fix: lint * fix: failing test Adjust the length of expected vmmaps * fix: tests again
This commit is contained in:
parent
c74a551a6d
commit
e8a8e737c8
|
@ -30,6 +30,15 @@ def pages_filter(gdbval_or_str):
|
|||
raise argparse.ArgumentTypeError("Unknown vmmap argument type.")
|
||||
|
||||
|
||||
def print_vmmap_table_header():
|
||||
"""
|
||||
Prints the table header for the vmmap command.
|
||||
"""
|
||||
width = 2 + 2 * pwndbg.gdblib.arch.ptrsize
|
||||
fmt_string = "%#{}s %#{}s %#4s %#8s %#6s %s".format(width, width)
|
||||
print(fmt_string % ("Start", "End", "Perm", "Size", "Offset", "File"))
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.description = """Print virtual memory map pages. Results can be filtered by providing address/module name.
|
||||
|
||||
|
@ -72,7 +81,7 @@ def vmmap(gdbval_or_str=None, writable=False, executable=False):
|
|||
return
|
||||
|
||||
print(M.legend())
|
||||
|
||||
print_vmmap_table_header()
|
||||
if len(pages) == 1 and isinstance(gdbval_or_str, integer_types):
|
||||
page = pages[0]
|
||||
print(M.get(page.vaddr, text=str(page) + " +0x%x" % (int(gdbval_or_str) - page.vaddr)))
|
||||
|
|
|
@ -69,11 +69,11 @@ def test_command_vmmap_on_coredump_on_crash_simple_binary(start_binary):
|
|||
vmmaps = gdb.execute("vmmap", to_string=True).splitlines()
|
||||
|
||||
# Basic asserts
|
||||
assert len(vmmaps) == len(expected_maps) + 1
|
||||
assert len(vmmaps) == len(expected_maps) + 2 # +2 for header and legend
|
||||
assert vmmaps[0] == "LEGEND: STACK | HEAP | CODE | DATA | RWX | RODATA"
|
||||
|
||||
# Split vmmaps
|
||||
vmmaps = [i.split() for i in vmmaps[1:]]
|
||||
vmmaps = [i.split() for i in vmmaps[2:]]
|
||||
|
||||
# Assert that vmmap output matches expected one
|
||||
assert vmmaps == expected_maps
|
||||
|
@ -91,7 +91,7 @@ def test_command_vmmap_on_coredump_on_crash_simple_binary(start_binary):
|
|||
|
||||
# Note: we will now see one less vmmap page as [vvar] will be missing
|
||||
assert vmmaps[0] == "LEGEND: STACK | HEAP | CODE | DATA | RWX | RODATA"
|
||||
vmmaps = [i.split() for i in vmmaps[1:]]
|
||||
vmmaps = [i.split() for i in vmmaps[2:]]
|
||||
assert len(vmmaps) == old_len_vmmaps - 1
|
||||
|
||||
# Fix up expected maps
|
||||
|
@ -134,6 +134,6 @@ def test_command_vmmap_on_coredump_on_crash_simple_binary(start_binary):
|
|||
gdb.execute("file")
|
||||
|
||||
vmmaps = gdb.execute("vmmap", to_string=True).splitlines()
|
||||
vmmaps = [i.split() for i in vmmaps[1:]]
|
||||
vmmaps = [i.split() for i in vmmaps[2:]]
|
||||
|
||||
assert_maps()
|
||||
|
|
Loading…
Reference in New Issue