#!/usr/bin/perl # bbsquash - squashes bb.out files to assist in checking # for complete test coverage # (makes linux "gcc -a" look more like Sun "cc -a") # # Typical usage: bbsquash bb.out # # Version 1.0 07Aug1998 Antonomasia # Version 1.1 10Aug1998 bugfix # Version 1.2 11Aug1998 bugfix - still seems to depend on # the program's CFLAGS # Version 1.3 28Aug1998 improvements following discussion with # Kragen Sitaker (kragen pobox.com) while (<>) { chomp; s/\s+/ /g; # normalising spaces $tmp=$_; # is this a block count line ? if ( $_ =~ /^ Block # *[0-9].*/ ) { $flag[$.]="count"; # we already have $_=$tmp; # (stated to mark symmetry between these blocks) s/(^ Block.*executed ).*/$1/; $first[$.]=$_; $_=$tmp; s/^ Block # *[0-9]* *: executed *[0-9]* //; $third[$.]=$_; # This will resemble the input line but with the number of # executions replaced by the " JOIN " string. $key[$.]=$first[$.]." JOIN ".$third[$.]; $_=$tmp; s/ time.*//; s/Block.*?executed //; $num=$_; # printf("ADDING %d to %s\n",$num, $key[$.]); $count{$key[$.]} += $num; } else { $record[$.]=$tmp; } } # now the output for($i=1;$i<$.;$i++) { if ( ("count" eq $flag[$i]) && ("USED" ne $count{$key[$i]}) ) { printf("KEY=%s\n",$key[$i]); printf(" %s%d %s\n",$first[$i], $count{$key[$i]}, $third[$i]); $count{$key[$i]}="USED"; } else { # to pass non-count lines unchanged printf("%s\n",$record[$i]); } } exit(0);