Ticket #390: strace-analyse.pl
File strace-analyse.pl, 464 bytes (added by , 11 years ago) |
---|
Line | |
---|---|
1 | #!/usr/bin/perl |
2 | use strict; |
3 | use warnings; |
4 | |
5 | my @fd = qw(STDIN STDOUT STDERR); |
6 | while (<>) { |
7 | if (/^pread\((\d+).*, (\d+), (\d+)\)/) { |
8 | my ($fd, $blocksize, $off) = ($1, $2, $3); |
9 | my $block = $off / $blocksize; |
10 | print "read $block from $fd[$fd]\n"; |
11 | } elsif (/^open\("(.*)".* = (\d+)/) { |
12 | $fd[$2] = $1; |
13 | } elsif (/^close\((\d+)/) { |
14 | $fd[$1] = undef; |
15 | } elsif (/^dup[23]?\((\d+).* = (\d+)/) { |
16 | $fd[$2] = $fd[$1]; |
17 | } |
18 | } |