Commit | Line | Data |
---|---|---|
249da916 ILT |
1 | #! /usr/bin/perl |
2 | ||
3 | # This script converts a "bb.out" file into a format | |
4 | # suitable for processing by gprof | |
5 | ||
6 | # Write a new-style gmon header | |
7 | ||
8 | print pack("A4Ix12", "gmon", 1); | |
9 | ||
10 | ||
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. | |
17 | ||
18 | $blockcount=0; | |
19 | ||
20 | while (<>) { | |
21 | if (/^File .*, ([0-9]+) basic blocks/) { | |
22 | print STDERR "Miscount: line $.\n" if ($blockcount != 0); | |
23 | $blockcount = $1; | |
24 | ||
25 | print pack("cI", 2, $blockcount); | |
26 | } | |
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); | |
30 | ||
31 | $count = $1; | |
32 | $addr = hex $2; | |
33 | ||
34 | print pack("II",$addr,$count); | |
35 | } | |
36 | } |