footprint.prl 1.22 KB
#!/usr/local/bin/perl5 -w
#
# Copyright (C) 1996-1998 by the Board of Trustees
#    of Leland Stanford Junior University.
# 
# This file is part of the SimOS distribution. 
# See LICENSE file for terms of the license. 
#

#
# Produce a gnuplot-type output out of the footprint function

require "getopts.pl";
&Getopts('i:n:');
$junk = 0;
if( defined($opt_i) ) { 
    $inputFile = $opt_i;
} else {
    $inputFile = "syscalls.stats";
}
if( defined($opt_n) ) { 
    $wload = $opt_n;
} else { 
    $wload = 0;
}

open(KSTATS,$inputFile);
while(<KSTATS>) {
    if(/^CONFIG/) { 
        ($junk,$index,$val) = split(' ');
        $config{$index} = $val;
        #print $index,"  XXXX ",$val,"\n";
    }
    if( /^FPRINT_D/ ) { 
        @x = split(" ");
        $syscall = $x[1];
        $index = $x[2];
        for $i (3..$#x) { 
            $val = hex($x[$i]);
            $pos = 0;
            while( $val > 0 ) { 
                if( ($val%2)==1) { 
                    $line = 0x60000000 + (($index+$i-3)* 32 + $pos)*  $config{'ICache.LineSize'} ;
                    print "$wload $syscall $line\n";
                    $val = $val -1;
                }
                $val = int($val/2);
                $pos = $pos + 1;
            }
        }
    }
}