0

How do I get a list of pages used by a process given its PID ? For each page, I would like to know its starting adress (should end with with 12*0 bits since pages are 4KB ?), and if it is writable/executable. A GDB-based solution would be nice too since i'm using it to debug.

Marco Bonelli
  • 63,369
  • 21
  • 118
  • 128
Aaa Bbb
  • 627
  • 4
  • 12
  • 2
    `info proc mappings` is what you're looking for: [GDB: Listing all mapped memory regions for a crashed process](https://stackoverflow.com/questions/5691193/gdb-listing-all-mapped-memory-regions-for-a-crashed-process) – Marco Bonelli Nov 27 '21 at 18:03
  • 1
    Linux shows it in terms of extents, not listing each page separately in a single multi-page mapping. Using `/proc//smaps`, you can see how much of the region is using transparent hugepages for anonymous mappings (actually 2M largepages, usually not 1G hugepages). – Peter Cordes Nov 28 '21 at 03:18

1 Answers1

0

The mapping of the virtual memory pages of a process from its pid is visible in the /proc filesystem, described in man proc(5) : The pseudo file maps should be enough, the pseudo file smaps shows more details.

cat /proc/[pid]/maps
cat /proc/[pid]/smaps
Eric Marchand
  • 619
  • 3
  • 10