missed from 2012-08-15 change
[deliverable/binutils-gdb.git] / gprof / bbconv.pl
CommitLineData
252b5132
RH
1#! /usr/bin/perl
2
3# This script converts a "bb.out" file into a format
4# suitable for processing by gprof
37503931 5#
651dbc76 6# Copyright 2001, 2007 Free Software Foundation, Inc.
37503931
NC
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
651dbc76 12# the Free Software Foundation; either version 3 of the License, or
37503931
NC
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
44eb1801
NC
22# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
23# 02110-1301, USA.
252b5132
RH
24
25# Write a new-style gmon header
26
27print 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
39while (<>) {
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}
This page took 0.50347 seconds and 4 git commands to generate.