pub struct MemoryRegion {
pub start: usize,
pub end: usize,
pub permissions: RegionPermissions,
pub offset: usize,
pub dev_major: u8,
pub dev_minor: u8,
pub inode: usize,
pub path: Option<String>,
}Expand description
Each row in /proc/[pid]/maps describes a region of contiguous virtual memory in a process or thread.
Fields§
§start: usizeThis is the starting address of the region in the process’s address space.
end: usizeThis is the ending address of the region in the process’s address space.
permissions: RegionPermissionsThis describes how pages in the region can be accessed.
There are four different permissions: read, write, execute, and shared.
If read/write/execute are disabled, a - will appear instead of the r/w/x .
If a region is not shared, it is private, so a p will appear instead of an s .
If the process attempts to access memory in a way that is not permitted,
a segmentation fault is generated.
Permissions can be changed using the mprotect(2) system call.
offset: usizeIf the region was mapped from a file (using mmap), this is the offset in the file
where the mapping begins. If the memory was not mapped from a file, it’s just 0.
dev_major: u8If the region was mapped from a file, this is the
major device number (in hex) where the file lives.
dev_minor: u8If the region was mapped from a file, this is the
minor device number (in hex) where the file lives.
inode: usizeIf the region was mapped from a file, this is the file number.
path: Option<String>If the region was mapped from a file, this is the name of the file.
This field is None for anonymous mapped regions.
There are also special regions with names like
[heap], [stack], or [vdso] .
The last one stands for virtual dynamic shared object.
It’s used by system calls to switch to kernel mode.