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
25 mapped memory regions.
31 Read and parse a maps file, returning an arrayref of regions (each
32 represented as a hashref). See "parse_maps_single_line" to see the
33 format of the hashrefs.
35 my $regions = read_maps(%args);
39 * file - Path to maps file
41 * pid - Process ID (one of file or pid is required)
43 * mnt - Absolute path where proc(5) is mounted (optional, default:
48 Returns a string with the contents of a maps file from the memory
51 my $file_content = write_maps(\@regions, %args);
53 This is the opposite of "read_maps".
57 * fh - Write maps to this open file handle (optional)
59 * file - Open this filepath and write maps to that file (optional)
61 parse_maps_single_line
63 Parse and return a single line from a maps file into a region
64 represented as a hashref.
66 my $region = parse_maps_single_line($line);
70 # address perms offset dev inode pathname
71 08048000-08056000 r-xp 00000000 03:0c 64593 /usr/sbin/gpm
76 address_start => 134512640,
77 address_end => 134569984,
85 pathname => '/usr/sbin/gpm',
88 format_maps_single_line
90 Return a single line for a maps file from a region represented as a
93 my $line = format_maps_single_line(\%region);
95 This is the opposite of "parse_maps_single_line".
99 proc(5) describes the file format.
103 Integer overloading may occur if you try to parse memory regions from
104 address spaces larger than your current architecture (or perl)
105 supports. This is currently not fatal, though you will get warnings
106 from perl that you probably shouldn't ignore.
110 Please report any bugs or feature requests on the bugtracker website
111 https://github.com/chazmcgarvey/Linux-Proc-Maps/issues
113 When submitting a bug or request, please include a test-file or a patch
114 to an existing test-file that illustrates the bug or desired feature.
118 Charles McGarvey <chazmcgarvey@brokenzipper.com>
120 COPYRIGHT AND LICENSE
122 This software is copyright (c) 2016 by Charles McGarvey.
124 This is free software; you can redistribute it and/or modify it under
125 the same terms as the Perl 5 programming language system itself.