3 Linux::Proc::Maps - Read and write /proc/\[pid\]/maps files
11 use Linux::Proc::Maps qw(read_maps);
14 my $vm_regions = read_maps(pid => $$);
16 # by pid with explicit procfs mount:
17 my $vm_regions = read_maps(mnt => '/proc', pid => 123);
20 my $vm_regions = read_maps(file => '/proc/456/maps');
24 This module reads and writes `/proc/[pid]/maps` files that contain listed mapped memory regions.
30 Read and parse a maps file, returning an arrayref of regions (each represented as a hashref). See
31 ["parse\_maps\_single\_line"](#parse_maps_single_line) to see the format of the hashrefs.
35 - `file` - Path to maps file
36 - `pid` - Process ID (one of `file` or `pid` is required)
37 - `mnt` - Absolute path where [proc(5)](http://man.he.net/man5/proc) is mounted (optional, default: `/proc`)
39 ## write\_maps \\@regions, %args
41 Returns a string with the contents of a maps file from the memory regions passed.
43 This is the opposite of ["read\_maps"](#read_maps).
47 - `fh` - Write maps to this open file handle (optional)
48 - `file` - Open this filepath and write maps to that file (optional)
50 ## parse\_maps\_single\_line $line
52 Parse and return a single line from a maps file into a region represented as a hashref.
56 # address perms offset dev inode pathname
57 08048000-08056000 r-xp 00000000 03:0c 64593 /usr/sbin/gpm
62 address_start => 134512640,
63 address_end => 134569984,
71 pathname => '/usr/sbin/gpm',
74 ## format\_maps\_single\_line \\%region
76 Return a single line for a maps file from a region represented as a hashref.
78 This is the opposite of ["parse\_maps\_single\_line"](#parse_maps_single_line).
82 [proc(5)](http://man.he.net/man5/proc) describes the file format.
86 Please report any bugs or feature requests on the bugtracker website
87 [https://github.com/chazmcgarvey/Linux-Proc-Maps/issues](https://github.com/chazmcgarvey/Linux-Proc-Maps/issues)
89 When submitting a bug or request, please include a test-file or a
90 patch to an existing test-file that illustrates the bug or desired
95 Charles McGarvey <chazmcgarvey@brokenzipper.com>
97 # COPYRIGHT AND LICENSE
99 This software is copyright (c) 2016 by Charles McGarvey.
101 This is free software; you can redistribute it and/or modify it under
102 the same terms as the Perl 5 programming language system itself.