Ticket #390: strace-analyse.pl

File strace-analyse.pl, 464 bytes (added by Olly Betts, 11 years ago)

perl script to analyse strace output

Line 
1#!/usr/bin/perl
2use strict;
3use warnings;
4
5my @fd = qw(STDIN STDOUT STDERR);
6while (<>) {
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}