| 1 | #! /usr/bin/perl
|
|---|
| 2 |
|
|---|
| 3 | # This script converts a "bb.out" file into a format
|
|---|
| 4 | # suitable for processing by gprof
|
|---|
| 5 | #
|
|---|
| 6 | # Copyright 2001 Free Software Foundation, Inc.
|
|---|
| 7 | #
|
|---|
| 8 | # This file is part of GNU Binutils.
|
|---|
| 9 | #
|
|---|
| 10 | # This program is free software; you can redistribute it and/or modify
|
|---|
| 11 | # it under the terms of the GNU General Public License as published by
|
|---|
| 12 | # the Free Software Foundation; either version 2 of the License, or
|
|---|
| 13 | # (at your option) any later version.
|
|---|
| 14 | #
|
|---|
| 15 | # This program is distributed in the hope that it will be useful,
|
|---|
| 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 18 | # GNU General Public License for more details.
|
|---|
| 19 | #
|
|---|
| 20 | # You should have received a copy of the GNU General Public License
|
|---|
| 21 | # along with this program; if not, write to the Free Software
|
|---|
| 22 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|---|
| 23 | # 02111-1307, USA.
|
|---|
| 24 |
|
|---|
| 25 | # Write a new-style gmon header
|
|---|
| 26 |
|
|---|
| 27 | print pack("A4Ix12", "gmon", 1);
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 | # The input file format contains header lines and data lines.
|
|---|
| 31 | # Header lines contain a count of how many data lines follow before
|
|---|
| 32 | # the next header line. $blockcount is set to the count that
|
|---|
| 33 | # appears in each header line, then decremented at each data line.
|
|---|
| 34 | # $blockcount should always be zero at the start of a header line,
|
|---|
| 35 | # and should never be zero at the start of a data line.
|
|---|
| 36 |
|
|---|
| 37 | $blockcount=0;
|
|---|
| 38 |
|
|---|
| 39 | while (<>) {
|
|---|
| 40 | if (/^File .*, ([0-9]+) basic blocks/) {
|
|---|
| 41 | print STDERR "Miscount: line $.\n" if ($blockcount != 0);
|
|---|
| 42 | $blockcount = $1;
|
|---|
| 43 |
|
|---|
| 44 | print pack("cI", 2, $blockcount);
|
|---|
| 45 | }
|
|---|
| 46 | if (/Block.*executed([ 0-9]+) time.* address= 0x([0-9a-fA-F]*)/) {
|
|---|
| 47 | print STDERR "Miscount: line $.\n" if ($blockcount == 0);
|
|---|
| 48 | $blockcount-- if ($blockcount > 0);
|
|---|
| 49 |
|
|---|
| 50 | $count = $1;
|
|---|
| 51 | $addr = hex $2;
|
|---|
| 52 |
|
|---|
| 53 | print pack("II",$addr,$count);
|
|---|
| 54 | }
|
|---|
| 55 | }
|
|---|