2 from .utils import pid_argument
4 class MemoryRegionDump(gdb.Command):
5 """Dump virtual memory regions associated with a process"""
6 def __init__(self) -> None:
7 super().__init__("vmrs", gdb.COMMAND_USER)
9 def invoke(self, argument: str, from_tty: bool) -> None:
10 argument = pid_argument(argument)
12 pid = gdb.parse_and_eval(f"{argument}->pid")
14 argument = f"&{argument}->mm.regions"
15 val = gdb.parse_and_eval(argument)
18 region_t = gdb.lookup_type("struct mm_region").pointer()
20 print("VMRS (pid: %d)"%(pid))
23 while(val["next"] != head):
24 region = val["next"].cast(region_t)
26 print( " 0x%x...0x%x [0x%x]"%(
27 region['start'], region['end'],
28 region['end'] - region['start']))
38 print( " attr: 0x%x (%s)"%(attr, "".join(attr_str)))
40 file = region["mfile"]
42 print( " anonymous region")
44 print( " file mapped:")
45 print( " dnode: %s @0x%x"%(file["dnode"]["name"]["value"].string(), file))
46 print( " frange: 0x%x+0x%x"%(region["foff"], region["flen"]))