Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chazmcgarvey/linux-proc-maps
Read and write /proc/[pid]/maps files
https://github.com/chazmcgarvey/linux-proc-maps
Last synced: 8 days ago
JSON representation
Read and write /proc/[pid]/maps files
- Host: GitHub
- URL: https://github.com/chazmcgarvey/linux-proc-maps
- Owner: chazmcgarvey
- License: other
- Created: 2016-11-26T00:10:15.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-09T21:11:27.000Z (almost 8 years ago)
- Last Synced: 2023-08-20T23:09:28.620Z (about 1 year ago)
- Language: Perl
- Homepage: https://metacpan.org/release/Linux-Proc-Maps
- Size: 27.3 KB
- Stars: 2
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: Changes
- License: LICENSE
Awesome Lists containing this project
README
# NAME
Linux::Proc::Maps - Read and write /proc/\[pid\]/maps files
# VERSION
version 0.002
# SYNOPSIS
use Linux::Proc::Maps qw(read_maps);
# by pid:
my $vm_regions = read_maps(pid => $$);# by pid with explicit procfs mount:
my $vm_regions = read_maps(mnt => '/proc', pid => 123);# by file:
my $vm_regions = read_maps(file => '/proc/456/maps');# DESCRIPTION
This module reads and writes `/proc/[pid]/maps` files that contain listed mapped memory regions.
# FUNCTIONS
## read\_maps
Read and parse a maps file, returning an arrayref of regions (each represented as a hashref). See
["parse\_maps\_single\_line"](#parse_maps_single_line) to see the format of the hashrefs.my $regions = read_maps(%args);
Arguments:
- `file` - Path to maps file
- `pid` - Process ID (one of `file` or `pid` is required)
- `mnt` - Absolute path where [proc(5)](http://man.he.net/man5/proc) is mounted (optional, default: `/proc`)## write\_maps
Returns a string with the contents of a maps file from the memory regions passed.
my $file_content = write_maps(\@regions, %args);
This is the opposite of ["read\_maps"](#read_maps).
Arguments:
- `fh` - Write maps to this open file handle (optional)
- `file` - Open this filepath and write maps to that file (optional)## parse\_maps\_single\_line
Parse and return a single line from a maps file into a region represented as a hashref.
my $region = parse_maps_single_line($line);
For example,
# address perms offset dev inode pathname
08048000-08056000 r-xp 00000000 03:0c 64593 /usr/sbin/gpmbecomes:
{
address_start => 134512640,
address_end => 134569984,
read => 1,
write => '',
execute => 1,
shared => '',
offset => 0,
device => '03:0c'
inode => '64593',
pathname => '/usr/sbin/gpm',
}## format\_maps\_single\_line
Return a single line for a maps file from a region represented as a hashref.
my $line = format_maps_single_line(\%region);
This is the opposite of ["parse\_maps\_single\_line"](#parse_maps_single_line).
# SEE ALSO
[proc(5)](http://man.he.net/man5/proc) describes the file format.
# CAVEATS
Integer overloading may occur if you try to parse memory regions from address spaces larger than
your current architecture (or perl) supports. This is currently not fatal, though you will get
warnings from perl that you probably shouldn't ignore.# BUGS
Please report any bugs or feature requests on the bugtracker website
[https://github.com/chazmcgarvey/Linux-Proc-Maps/issues](https://github.com/chazmcgarvey/Linux-Proc-Maps/issues)When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired
feature.# AUTHOR
Charles McGarvey
# COPYRIGHT AND LICENSE
This software is copyright (c) 2016 by Charles McGarvey.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.