Skip to content

Commit

Permalink
contrib/vmmap.py: use new for_each_vma() helper
Browse files Browse the repository at this point in the history
Signed-off-by: Omar Sandoval <[email protected]>
  • Loading branch information
osandov committed Oct 30, 2023
1 parent eab64bd commit cf0b754
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions contrib/vmmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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} ",
Expand All @@ -53,5 +45,3 @@
pgoff = 0

print(f"{pgoff:08x} {major:02x}:{minor:02x} {inode:<16} {path}")

vma = vma.vm_next

0 comments on commit cf0b754

Please sign in to comment.