diff --git a/contrib/vmmap.py b/contrib/vmmap.py index ed3418747..f10f9167b 100755 --- a/contrib/vmmap.py +++ b/contrib/vmmap.py @@ -9,6 +9,7 @@ from drgn.helpers.linux.device import MAJOR, MINOR from drgn.helpers.linux.fs import d_path +from drgn.helpers.linux.mm import for_each_vma from drgn.helpers.linux.pid import find_task if len(sys.argv) != 2: @@ -19,21 +20,12 @@ if not task: sys.exit(f"Cannot find task {pid}") -try: - vma = task.mm.mmap -except AttributeError: - sys.exit('maple tree VMA mmap is not supported yet (v6.1+)') - FLAGS = ((0x1, "r"), (0x2, "w"), (0x4, "x")) PAGE_SHIFT = prog["PAGE_SHIFT"] print("Start End Flgs Offset Dev Inode File path") -# Starting with 763ecb035029f500d7e6d ("mm: remove the vma linked list") (in v6.1), -# the VMA mmap linked list is replaced with maple tree which is not supported right now: -# https://github.com/osandov/drgn/issues/261 - -while vma: +for vma in for_each_vma(task.mm): flags = "".join([v if f & vma.vm_flags else "-" for f, v in FLAGS]) flags += "s" if vma.vm_flags & 0x8 else "p" print(f"{vma.vm_start.value_():0x}-{vma.vm_end.value_():0x} {flags} ", @@ -53,5 +45,3 @@ pgoff = 0 print(f"{pgoff:08x} {major:02x}:{minor:02x} {inode:<16} {path}") - - vma = vma.vm_next