#----------------------------------------
# see the usage function for description
#----------------------------------------
print "===============================================\n";
print "=== tso_analyze ===\n";
print "===============================================\n";
my @Options = qw(debug help);
GetOptions(\%opt, @Options) or die "Error in arguments!\n";
my($debug) = $opt{debug};
#---------------------------------------------------------
print "Preparing the prop file.\n";
open(DIAG, "diag.s") || die " BAD BAD diag.s";
open(TEMP , ">prop") || die " BAD BAD prop";
if(/no tsotool postprocessing/){
if(/old tsotool postprocessing/){
elsif(/\!\s+TSOTOOL.PROCESSOR/){
print TEMP "TSOTOOL.MODE ANALYZE\n";
print "Prepared the prop file.\n";
my $logfile= (-f "sim.log") ? "sim.log" :
(-f "sim.log.gz") ? "sim.log.gz" :
die "Logfile not found\n";
print " Now will extract per location store order\n";
print "Finished Extracting\n";
if ($logfile =~ /\.gz$/) {
open (LOG_TR, "gunzip -c $logfile | tail |");
open (LOG_TR, "tail $logfile |");
if (/hit\s*good\s*trap/) {
system("touch diag.failure");
print "Simulation failed, results will NOT be analyzed\n";
print "Now will run tsotool\n";
print "Finished running tsotool\n";
print "This diag is not a tsotool diag or is a tsotool diag which should not be analyzed.\n";
#========================================================================
# extract - extract from sim.log whatever is relevant - FP regs, INT regs
#========================================================================
my ($i, $k, $time, $spc, $thr, $proc, $reg, $val, $win);
my(@tl, @FPLINES, @INTLINES, %SJMLINES);
for ($i = 0; $i < 32; $i++){
my $logfile= (-f "sim.log") ? "sim.log" :
(-f "sim.log.gz") ? "sim.log.gz" :
die "Logfile not found\n";
if($logfile =~ /\.gz$/) {
open(VCS, "gunzip -c $logfile | egrep 'jbus_mon|reg' |") || die "cannot open gunzip -c $logfile";
open(VCS, "egrep 'jbus_mon|reg' $logfile| ") || die "cannot open $logfile";
if(/^(\d+):.*reg.updated\s*->\s*spc.(\d).\s*thread.(\d)/){
if(/float_reg.updated.*reg#\((\w+)\).*val = (\w+)/){
push @{$FPLINES[$proc]}, sprintf("%-4s %-4d %-20s\t\t\t %-30s\n",$reg, $proc, $val, $time);
elsif(/window.(\w+).*reg#\((\w+)\).*val = (\w+)/){
push @{$INTLINES[$proc]}, sprintf("%-4s %-4d %-20s\t\t\t%-20s\n", $reg, $proc, $val, $time);
elsif(/tl_reg.updated.*window.(\w+).*val = (\w+)/){
printf "%-10s: C%dT%d\t\tTL REG UPDATE <TL = %d>\n", $time, $spc, $thr, $tl[$proc] if($debug);
#37275441: jbus_monitor(jbus_mon): started ReadToDiscard agent_id=12, transaction_id=0 address=01171800000, identifier=27
elsif(/(\d+):\s*jbus_mon.*:\s*started ReadToDiscard\s*agent_id=(\d+).*identifier=(\d+)/){
print "agent id = $2 identifier = $3\n" if($debug);
# alex, taking care of NCRD transactions
#15905: jbus_monitor(jbus_mon): started NonCachedRead agent_id=12, transaction_id=0 address=7cf10800050, identifier=179, dbg=4
elsif(/(\d+):\s*jbus_mon.*:\s*started NonCachedRead\s*agent_id=(\d+).*identifier=(\d+)/){
print "agent id = $2 identifier = $3\n" if($debug);
#37203537: jbus_monitor(jbus_mon): RDD 01170000000 data driver=0 state = I identifier=23 start time=36782385
elsif(/(\d+):\s*jbus_mon.*:\s*RDD\s*([\dabcdefABCDEF]+)\s*([\dabcdefABCDEF]+).*identifier=(\d+)/){
my @da = split '', $data;
for(my $i = 1; $i <=$#da; $i++){
$dafinal[$k++] = $da[$i];
$data = join '', @dafinal;
if(! exists $agent_id{$identifier}) {
die "Could not find agent id for $identifier \n";
#push @SJMLINES, sprintf("%-20s %-2d %-20s %-2d %-128s\n", $time, $agent_id{$identifier}, $addr, $size, $data);
# alex - SJMLINES hashing lines by identifier
$SJMLINES{$identifier} = sprintf("%-20s %-2d %-20s %-2d %-128s\n", $time, $agent_id{$identifier}, $addr, $size, $data);
# alex - taking care of NCRD transactions
# count number of -'s before data, adjust address
# count data size, calculate size
#113: jbus_monitor(jbus_mon): NCRD 7cf10800100 000186a3------------------------ driver=4 identifier=194 start time=17
elsif(/(\d+):\s*jbus_mon.*:\s*NCRD\s*([\dabcdefABCDEF]+)\s+(-*)([\dabcdefABCDEF]+)-*.*identifier=(\d+)/){
# my is important - don't want to override global $size
my $size = length($data)/2;
if (length($ld_dashes) == 8) {
elsif (length($ld_dashes) == 16) {
elsif (length($ld_dashes) == 24) {
if(! exists $agent_id{$identifier}) {
die "Could not find agent id for $identifier \n";
$SJMLINES{$identifier} = sprintf("%-20s %-2d %-20s %-2d %-128s\n", $time, $agent_id{$identifier}, $addr, $size, $data);
#--------------------------------------------------------------------
open(TSOINT, ">diag.load-values.int") || die " BAD BAD int";
open(TSOFP , ">diag.load-values.fp") || die " BAD BAD fp";
open(TSOSJM, ">diag.load-values.sjm") || die " BAD BAD sjm";
foreach $i (0..$#INTLINES){
foreach $k (0..$#{$tmp}){
$line =~ /^(%\S+)\s+(\d+)\s+(.*)/;
print "$1 $writeout $3\n" if($debug);;
print TSOINT "$1 $writeout $3\n";
$writeout++ if($#{$tmp} >=0);
foreach $i (0..$#FPLINES){
foreach $k (0..$#{$tmp}){
$line =~ /^(%\S+)\s+(\d+)\s+(.*)/;
print TSOFP "$1 $writeout $3\n";
$writeout++ if($#{$tmp} >=0);
# sorting SJM lines by identifier and output
foreach $i (sort {$a <=> $b} keys(%SJMLINES)){
print $SJMLINES{$i} if($debug);
print TSOSJM $SJMLINES{$i};
#====================================================================
# not sure why the function came here in the first place
# performs a simple check.
#====================================================================
my($length) = length($pc);
die " tso_analyze: ERROR something is wrong with the datum length $length\n";
#=========================================================================
---------------------------------------------------------------------------
Do a tsotool post-processing analysis.
---------------------------------------------------------------------------