Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

import Linux-Smaps 0.06 from CPAN

git-cpan-module:   Linux-Smaps
git-cpan-version:  0.06
git-cpan-authorid: OPI
git-cpan-file:     authors/id/O/OP/OPI/Linux-Smaps-0.06.tar.gz
  • Loading branch information...
commit fd406f758e312c5391750f3aa8f610b52dcdad02 1 parent 6a218c0
@tfoertsch tfoertsch authored schwern committed
View
5 Changes
@@ -1,5 +1,10 @@
Revision history for Perl extension Linux::Smaps.
+0.06 Wed Jun 4 11:39:18 CEST 2008
+ - sometimes vmas are listed twice in /proc/self/smaps.
+ (perhaps a kernel bug) Linux::Smaps ignores the duplicates
+ - using POSIX::setlocale during test to ensure english error messages
+
0.05 Tue Oct 9 10:42:43 CEST 2007
- VMA accessor methods and Smaps summary methods are created on
the fly. So, new features added by the kernel won't break the
View
2  MANIFEST
@@ -2,6 +2,8 @@ Changes
Makefile.PL
MANIFEST
README
+t/double-vdso
+t/single-vdso
t/smaps
t/smaps64
t/Linux-Smaps.t
View
23 META.yml
@@ -1,11 +1,14 @@
-# http://module-build.sourceforge.net/META-spec.html
-#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
-name: Linux-Smaps
-version: 0.05
-version_from: lib/Linux/Smaps.pm
-installdirs: site
-requires:
+--- #YAML:1.0
+name: Linux-Smaps
+version: 0.06
+abstract: a Perl interface to /proc/PID/smaps
+license: ~
+generated_by: ExtUtils::MakeMaker version 6.36
+distribution_type: module
+requires:
Class::Member: 1.3
-
-distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.30
+meta-spec:
+ url: http://module-build.sourceforge.net/META-spec-v1.2.html
+ version: 1.2
+author:
+ - Torsten Foertsch <torsten.foertsch@gmx.net>
View
33 lib/Linux/Smaps.pm
@@ -7,7 +7,7 @@ no warnings qw(uninitialized portable);
use Class::Member::HASH qw{pid lasterror filename procdir
_elem -CLASS_MEMBERS};
-our $VERSION = '0.05';
+our $VERSION = '0.06';
sub new {
my $class=shift;
@@ -52,13 +52,14 @@ sub update {
$name=$I->procdir.'/'.$I->pid.'/smaps';
}
- open my $f, $name or do {
+ open my $f, '<', $name or do {
$I->lasterror="Cannot open $name: $!";
return;
};
my $current;
$I->_elem=[];
+ my %cache;
my $l;
while( defined($l=<$f>) ) {
if( $l=~/([\da-f]+)-([\da-f]+)\s # range
@@ -69,19 +70,23 @@ sub update {
(.*?) # file name
(\s\(deleted\))?$
/xi ) {
- push @{$I->_elem}, $current=Linux::Smaps::VMA->new;
+ $current=Linux::Smaps::VMA->new;
$current->vma_start=hex $1;
$current->vma_end=hex $2;
- $current->r=($3 eq 'r');
- $current->w=($4 eq 'w');
- $current->x=($5 eq 'x');
- $current->mayshare=($6 eq 's');
- $current->file_off=hex $7;
- $current->dev_major=hex $8;
- $current->dev_minor=hex $9;
- $current->inode=$10;
- $current->file_name=$11;
- $current->is_deleted=defined( $12 );
+ unless( exists $cache{$current->vma_start."\0".$current->vma_end} ) {
+ $cache{$current->vma_start."\0".$current->vma_end}=1;
+ push @{$I->_elem}, $current;
+ $current->r=($3 eq 'r');
+ $current->w=($4 eq 'w');
+ $current->x=($5 eq 'x');
+ $current->mayshare=($6 eq 's');
+ $current->file_off=hex $7;
+ $current->dev_major=hex $8;
+ $current->dev_minor=hex $9;
+ $current->inode=$10;
+ $current->file_name=$11;
+ $current->is_deleted=defined( $12 );
+ }
} elsif( $l=~/^(\w+):\s*(\d+) kB$/ ) {
my $m=lc $1;
$m=~s/\s/_/g;
@@ -126,7 +131,7 @@ sub update {
}
BEGIN {
- foreach my $n (qw{heap stack vdso}) {
+ foreach my $n (qw{heap stack vdso vsyscall}) {
eval <<"EOE";
sub $n {
my \$I=shift;
View
10 t/Linux-Smaps.t
@@ -1,6 +1,8 @@
-use Test::More tests => 34;
+use Test::More tests => 35;
+use POSIX ();
BEGIN { use_ok('Linux::Smaps') };
+POSIX::setlocale( &POSIX::LC_ALL, "C" );
my ($s, $old);
my $fn=$0;
@@ -119,6 +121,12 @@ SKIP: {
ok( $@=~/Integer overflow in hexadecimal number/, "integer overflow" );
}
+my $s1=Linux::Smaps->new(filename=>$fn.'/t/double-vdso');
+my $s2=Linux::Smaps->new(filename=>$fn.'/t/single-vdso');
+
+my ($newlist, $difflist, $oldlist)=$s1->diff( $s2 );
+ok @$newlist==0 && @$difflist==0 && @$oldlist==0, 'double-vdso match single-vdso';
+
# Local Variables:
# mode: perl
# End:
View
208 t/double-vdso
@@ -0,0 +1,208 @@
+08048000-08076000 r-xp 00000000 08:06 939194 /bin/grep
+Size: 184 kB
+Rss: 64 kB
+Shared_Clean: 0 kB
+Shared_Dirty: 0 kB
+Private_Clean: 64 kB
+Private_Dirty: 0 kB
+Referenced: 64 kB
+08076000-08078000 rw-p 0002d000 08:06 939194 /bin/grep
+Size: 8 kB
+Rss: 8 kB
+Shared_Clean: 0 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 8 kB
+Referenced: 8 kB
+08078000-08099000 rw-p 08078000 00:00 0 [heap]
+Size: 132 kB
+Rss: 20 kB
+Shared_Clean: 0 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 20 kB
+Referenced: 20 kB
+b7d4f000-b7d8e000 r--p 00000000 08:06 1214546 /usr/lib/locale/en_US.utf8/LC_CTYPE
+Size: 252 kB
+Rss: 16 kB
+Shared_Clean: 16 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 16 kB
+b7d8e000-b7e6e000 r--p 00000000 08:06 1216958 /usr/lib/locale/en_US.utf8/LC_COLLATE
+Size: 896 kB
+Rss: 12 kB
+Shared_Clean: 12 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 12 kB
+b7e6e000-b7e6f000 rw-p b7e6e000 00:00 0
+Size: 4 kB
+Rss: 4 kB
+Shared_Clean: 0 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 4 kB
+Referenced: 4 kB
+b7e6f000-b7f9c000 r-xp 00000000 08:06 1137904 /lib/libc-2.6.1.so
+Size: 1204 kB
+Rss: 360 kB
+Shared_Clean: 360 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 360 kB
+b7f9c000-b7f9d000 r--p 0012c000 08:06 1137904 /lib/libc-2.6.1.so
+Size: 4 kB
+Rss: 4 kB
+Shared_Clean: 0 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 4 kB
+Referenced: 4 kB
+b7f9d000-b7f9f000 rw-p 0012d000 08:06 1137904 /lib/libc-2.6.1.so
+Size: 8 kB
+Rss: 8 kB
+Shared_Clean: 0 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 8 kB
+Referenced: 8 kB
+b7f9f000-b7fa3000 rw-p b7f9f000 00:00 0
+Size: 16 kB
+Rss: 16 kB
+Shared_Clean: 0 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 16 kB
+Referenced: 16 kB
+b7fb3000-b7fb4000 r--p 00000000 08:06 1214539 /usr/lib/locale/en_US.utf8/LC_NUMERIC
+Size: 4 kB
+Rss: 4 kB
+Shared_Clean: 4 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 4 kB
+b7fb4000-b7fb5000 r--p 00000000 08:06 1200923 /usr/lib/locale/en_US.utf8/LC_TIME
+Size: 4 kB
+Rss: 4 kB
+Shared_Clean: 4 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 4 kB
+b7fb5000-b7fb6000 r--p 00000000 08:06 1200922 /usr/lib/locale/en_US.utf8/LC_MONETARY
+Size: 4 kB
+Rss: 4 kB
+Shared_Clean: 4 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 4 kB
+b7fb6000-b7fb7000 r--p 00000000 08:06 1200514 /usr/lib/locale/en_US.utf8/LC_MESSAGES/SYS_LC_MESSAGES
+Size: 4 kB
+Rss: 4 kB
+Shared_Clean: 4 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 4 kB
+b7fb7000-b7fb8000 r--p 00000000 08:06 1200370 /usr/lib/locale/en_US.utf8/LC_PAPER
+Size: 4 kB
+Rss: 4 kB
+Shared_Clean: 4 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 4 kB
+b7fb8000-b7fb9000 r--p 00000000 08:06 1200444 /usr/lib/locale/en_US.utf8/LC_NAME
+Size: 4 kB
+Rss: 4 kB
+Shared_Clean: 4 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 4 kB
+b7fb9000-b7fba000 r--p 00000000 08:06 1198492 /usr/lib/locale/en_US.utf8/LC_ADDRESS
+Size: 4 kB
+Rss: 4 kB
+Shared_Clean: 4 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 4 kB
+b7fba000-b7fbb000 r--p 00000000 08:06 1200335 /usr/lib/locale/en_US.utf8/LC_TELEPHONE
+Size: 4 kB
+Rss: 4 kB
+Shared_Clean: 4 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 4 kB
+b7fbb000-b7fbc000 r--p 00000000 08:06 1200925 /usr/lib/locale/en_US.utf8/LC_MEASUREMENT
+Size: 4 kB
+Rss: 4 kB
+Shared_Clean: 4 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 4 kB
+b7fbc000-b7fc3000 r--s 00000000 08:06 1185578 /usr/lib/gconv/gconv-modules.cache
+Size: 28 kB
+Rss: 24 kB
+Shared_Clean: 24 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 24 kB
+b7fc3000-b7fc4000 r--p 00000000 08:06 1200921 /usr/lib/locale/en_US.utf8/LC_IDENTIFICATION
+Size: 4 kB
+Rss: 4 kB
+Shared_Clean: 4 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 4 kB
+b7fc4000-b7fde000 r-xp 00000000 08:06 1138761 /lib/ld-2.6.1.so
+Size: 104 kB
+Rss: 92 kB
+Shared_Clean: 92 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 92 kB
+b7fde000-b7fe0000 rw-p 0001a000 08:06 1138761 /lib/ld-2.6.1.so
+Size: 8 kB
+Rss: 8 kB
+Shared_Clean: 0 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 8 kB
+Referenced: 8 kB
+bfe65000-bfe7a000 rw-p bfe65000 00:00 0 [stack]
+Size: 84 kB
+Rss: 16 kB
+Shared_Clean: 0 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 16 kB
+Referenced: 16 kB
+ffffe000-fffff000 r-xp 00000000 00:00 0 [vdso]
+Size: 4 kB
+Rss: 0 kB
+Shared_Clean: 0 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 0 kB
+ffffe000-fffff000 r-xp 00000000 00:00 0 [vdso]
+Size: 4 kB
+Rss: 0 kB
+Shared_Clean: 0 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 0 kB
View
200 t/single-vdso
@@ -0,0 +1,200 @@
+08048000-08076000 r-xp 00000000 08:06 939194 /bin/grep
+Size: 184 kB
+Rss: 64 kB
+Shared_Clean: 0 kB
+Shared_Dirty: 0 kB
+Private_Clean: 64 kB
+Private_Dirty: 0 kB
+Referenced: 64 kB
+08076000-08078000 rw-p 0002d000 08:06 939194 /bin/grep
+Size: 8 kB
+Rss: 8 kB
+Shared_Clean: 0 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 8 kB
+Referenced: 8 kB
+08078000-08099000 rw-p 08078000 00:00 0 [heap]
+Size: 132 kB
+Rss: 20 kB
+Shared_Clean: 0 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 20 kB
+Referenced: 20 kB
+b7d4f000-b7d8e000 r--p 00000000 08:06 1214546 /usr/lib/locale/en_US.utf8/LC_CTYPE
+Size: 252 kB
+Rss: 16 kB
+Shared_Clean: 16 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 16 kB
+b7d8e000-b7e6e000 r--p 00000000 08:06 1216958 /usr/lib/locale/en_US.utf8/LC_COLLATE
+Size: 896 kB
+Rss: 12 kB
+Shared_Clean: 12 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 12 kB
+b7e6e000-b7e6f000 rw-p b7e6e000 00:00 0
+Size: 4 kB
+Rss: 4 kB
+Shared_Clean: 0 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 4 kB
+Referenced: 4 kB
+b7e6f000-b7f9c000 r-xp 00000000 08:06 1137904 /lib/libc-2.6.1.so
+Size: 1204 kB
+Rss: 360 kB
+Shared_Clean: 360 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 360 kB
+b7f9c000-b7f9d000 r--p 0012c000 08:06 1137904 /lib/libc-2.6.1.so
+Size: 4 kB
+Rss: 4 kB
+Shared_Clean: 0 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 4 kB
+Referenced: 4 kB
+b7f9d000-b7f9f000 rw-p 0012d000 08:06 1137904 /lib/libc-2.6.1.so
+Size: 8 kB
+Rss: 8 kB
+Shared_Clean: 0 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 8 kB
+Referenced: 8 kB
+b7f9f000-b7fa3000 rw-p b7f9f000 00:00 0
+Size: 16 kB
+Rss: 16 kB
+Shared_Clean: 0 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 16 kB
+Referenced: 16 kB
+b7fb3000-b7fb4000 r--p 00000000 08:06 1214539 /usr/lib/locale/en_US.utf8/LC_NUMERIC
+Size: 4 kB
+Rss: 4 kB
+Shared_Clean: 4 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 4 kB
+b7fb4000-b7fb5000 r--p 00000000 08:06 1200923 /usr/lib/locale/en_US.utf8/LC_TIME
+Size: 4 kB
+Rss: 4 kB
+Shared_Clean: 4 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 4 kB
+b7fb5000-b7fb6000 r--p 00000000 08:06 1200922 /usr/lib/locale/en_US.utf8/LC_MONETARY
+Size: 4 kB
+Rss: 4 kB
+Shared_Clean: 4 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 4 kB
+b7fb6000-b7fb7000 r--p 00000000 08:06 1200514 /usr/lib/locale/en_US.utf8/LC_MESSAGES/SYS_LC_MESSAGES
+Size: 4 kB
+Rss: 4 kB
+Shared_Clean: 4 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 4 kB
+b7fb7000-b7fb8000 r--p 00000000 08:06 1200370 /usr/lib/locale/en_US.utf8/LC_PAPER
+Size: 4 kB
+Rss: 4 kB
+Shared_Clean: 4 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 4 kB
+b7fb8000-b7fb9000 r--p 00000000 08:06 1200444 /usr/lib/locale/en_US.utf8/LC_NAME
+Size: 4 kB
+Rss: 4 kB
+Shared_Clean: 4 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 4 kB
+b7fb9000-b7fba000 r--p 00000000 08:06 1198492 /usr/lib/locale/en_US.utf8/LC_ADDRESS
+Size: 4 kB
+Rss: 4 kB
+Shared_Clean: 4 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 4 kB
+b7fba000-b7fbb000 r--p 00000000 08:06 1200335 /usr/lib/locale/en_US.utf8/LC_TELEPHONE
+Size: 4 kB
+Rss: 4 kB
+Shared_Clean: 4 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 4 kB
+b7fbb000-b7fbc000 r--p 00000000 08:06 1200925 /usr/lib/locale/en_US.utf8/LC_MEASUREMENT
+Size: 4 kB
+Rss: 4 kB
+Shared_Clean: 4 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 4 kB
+b7fbc000-b7fc3000 r--s 00000000 08:06 1185578 /usr/lib/gconv/gconv-modules.cache
+Size: 28 kB
+Rss: 24 kB
+Shared_Clean: 24 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 24 kB
+b7fc3000-b7fc4000 r--p 00000000 08:06 1200921 /usr/lib/locale/en_US.utf8/LC_IDENTIFICATION
+Size: 4 kB
+Rss: 4 kB
+Shared_Clean: 4 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 4 kB
+b7fc4000-b7fde000 r-xp 00000000 08:06 1138761 /lib/ld-2.6.1.so
+Size: 104 kB
+Rss: 92 kB
+Shared_Clean: 92 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 92 kB
+b7fde000-b7fe0000 rw-p 0001a000 08:06 1138761 /lib/ld-2.6.1.so
+Size: 8 kB
+Rss: 8 kB
+Shared_Clean: 0 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 8 kB
+Referenced: 8 kB
+bfe65000-bfe7a000 rw-p bfe65000 00:00 0 [stack]
+Size: 84 kB
+Rss: 16 kB
+Shared_Clean: 0 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 16 kB
+Referenced: 16 kB
+ffffe000-fffff000 r-xp 00000000 00:00 0 [vdso]
+Size: 4 kB
+Rss: 0 kB
+Shared_Clean: 0 kB
+Shared_Dirty: 0 kB
+Private_Clean: 0 kB
+Private_Dirty: 0 kB
+Referenced: 0 kB
Please sign in to comment.
Something went wrong with that request. Please try again.