3 # This script converts a "bb.out" file into a format
4 # suitable for processing by gprof
6 # Write a new-style gmon header
8 print pack("A4Ix12", "gmon", 1);
11 # The input file format contains header lines and data lines.
12 # Header lines contain a count of how many data lines follow before
13 # the next header line. $blockcount is set to the count that
14 # appears in each header line, then decremented at each data line.
15 # $blockcount should always be zero at the start of a header line,
16 # and should never be zero at the start of a data line.
21 if (/^File .*, ([0-9]+) basic blocks/) {
22 print STDERR
"Miscount: line $.\n" if ($blockcount != 0);
25 print pack("cI", 2, $blockcount);
27 if (/Block.*executed([ 0-9]+) time.* address= 0x([0-9a-fA-F]*)/) {
28 print STDERR
"Miscount: line $.\n" if ($blockcount == 0);
29 $blockcount-- if ($blockcount > 0);
34 print pack("II",$addr,$count);