refactor: use .format() properly for displaying vmmap rows (#1316)

pull/1319/head
alufers 3 years ago committed by GitHub
parent 5a323b4967
commit d812acf55a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -34,9 +34,17 @@ def print_vmmap_table_header():
""" """
Prints the table header for the vmmap command. Prints the table header for the vmmap command.
""" """
width = 2 + 2 * pwndbg.gdblib.arch.ptrsize print(
fmt_string = "%#{}s %#{}s %#4s %#8s %#6s %s".format(width, width) "{start:>{width}} {end:>{width}} {permstr} {size:>8} {offset:>6} {objfile}".format(
print(fmt_string % ("Start", "End", "Perm", "Size", "Offset", "File")) start="Start",
end="End",
permstr="Perm",
size="Size",
offset="Offset",
objfile="File",
width=2 + 2 * pwndbg.gdblib.arch.ptrsize,
)
)
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()

@ -129,16 +129,14 @@ class Page:
) )
def __str__(self): def __str__(self):
width = 2 + 2 * pwndbg.gdblib.arch.ptrsize return "{start:#{width}x} {end:#{width}x} {permstr} {size:8x} {offset:6x} {objfile}".format(
fmt_string = "%#{}x %#{}x %s %8x %-6x %s" start=self.vaddr,
fmt_string = fmt_string.format(width, width) end=self.vaddr + self.memsz,
return fmt_string % ( permstr=self.permstr,
self.vaddr, size=self.memsz,
self.vaddr + self.memsz, offset=self.offset,
self.permstr, objfile=self.objfile or "",
self.memsz, width=2 + 2 * pwndbg.gdblib.arch.ptrsize,
self.offset,
self.objfile or "",
) )
def __repr__(self): def __repr__(self):

Loading…
Cancel
Save