🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #42230

Profiling data from gcc/g++

#42230
From: James Taylor
Date: Tue, 02 Jan 1996 00:00
129 lines
7320 bytes
I have a relitively small, critical module which I need to test in
excruciating detail.  As part of my test I would like to use basic
block profiling (-a) to provide a better look at test coverage.
In doing so I've turned up questions in interpreting the basic block
information and assembly generated by gcc.

Everything is compiled with "gcc -g -a -c xxx.c".
Everything is linked with "gcc -g -a *.o -o prog".
Tests were executed under gcc 2.7.0 on a SS20/50, SunOS 4.1.3_U1
and on an IBM-PC 486/66 Linux 1.3.8, with identical results.

Exerps from "bb.out" and lines of code related to those which generated
the basic block profile are appended to the text.

A small number of basic blocks, for example, operations in lines
96-97 and 127-128 in test1.c below, are identified as unexecuted by
my testing.  My problem is in identifying, from the data recorded in
bb.out and the intermediate assembly precisely which blocks are 
unexecuted and why.

The basic blocks included represent straight line "C" code in the
intitialization and calculation of a value.  Divisions and modulus 
operations are all by constants, with no need therefore to check 
for zero divisors, so all of the generated asm should be single path.
However there are blocks of code which appear to be dead, associated 
with zero checks in this code.

In analyzing the output of gcc, and in matching assembly labels to 
profiling output I must make alot of assumptions. Could anyone answer 
the following specific questions:

Is the Block# label identified in bb.out identifiable as a particular asm
label? Block# appear to correspond to the assembly label
(in the file produced via "gcc -g -a -S test1.c") LPB# (offset by one).

The bb.out file refers to a test1.d file, is this a file useful in
identifying exactly what operation in the source is producing the asm
which is unexecuted during my testing?

If so, how do I generate that file, and make it stick around after
compilation?

Am I correct in assuming that the unexecuted blocks really may
represent unexecutable detritus, which could be optimized out if
a constant divisor was recognized in this calculation?

And finally - is there a document that I'm not reading and should,
which goes into the hairy details of asm labels, block numbers, and the
intended use of the profiling tools?

Thanks much for any assistance you can give.

James Taylor
james@halcyon.com
-OR-
james@physio-control.com

start of included material
--------------------------------------------------------------------------

-- exerp from bb.out --

Basic block profiling finished on Fri Sep  8 07:34:31 1995

... deleted ...

File /home/james/test1.d, 31 basic blocks 

    Block # 1: executed   2599 time(s) address= 0x408c function= test1 line=  89 file= test1.c
    Block # 2: executed      0 time(s) address= 0x40e4 function= test1 line=  96 file= test1.c
    Block # 3: executed   2599 time(s) address= 0x40f8 function= test1 line=  96 file= test1.c
    Block # 4: executed      0 time(s) address= 0x4134 function= test1 line=  97 file= test1.c
    Block # 5: executed   2599 time(s) address= 0x4148 function= test1 line=  97 file= test1.c
    Block # 6: executed 834279 time(s) address= 0x4164 function= test1 line= 101 file= test1.c
    Block # 7: executed   2599 time(s) address= 0x418c function= test1 line= 101 file= test1.c
    Block # 8: executed 831680 time(s) address= 0x41a4 function= test1 line= 103 file= test1.c
    Block # 9: executed 409047 time(s) address= 0x41e8 function= test1 line= 103 file= test1.c
    Block #10: executed 831680 time(s) address= 0x4200 function= test1 line= 103 file= test1.c
    Block #11: executed 267980 time(s) address= 0x4240 function= test1 line= 106 file= test1.c
    Block #12: executed 563700 time(s) address= 0x4268 function= test1 line= 108 file= test1.c
    Block #13: executed  14261 time(s) address= 0x42a4 function= test1 line= 110 file= test1.c
    Block #14: executed 831680 time(s) address= 0x42c4 function= test1 line= 113 file= test1.c
    Block #15: executed 372987 time(s) address= 0x4300 function= test1 line= 115 file= test1.c
    Block #16: executed 458693 time(s) address= 0x4328 function= test1 line= 117 file= test1.c
    Block #17: executed  10773 time(s) address= 0x4364 function= test1 line= 119 file= test1.c
    Block #18: executed 831680 time(s) address= 0x4384 function= test1 line= 101 file= test1.c
    Block #19: executed   2599 time(s) address= 0x43ac function= test1 line= 127 file= test1.c
    Block #20: executed      0 time(s) address= 0x43ec function= test1 line= 127 file= test1.c
    Block #21: executed   2599 time(s) address= 0x4400 function= test1 line= 127 file= test1.c
    Block #22: executed      0 time(s) address= 0x4444 function= test1 line= 127 file= test1.c
    Block #23: executed   2599 time(s) address= 0x4458 function= test1 line= 127 file= test1.c
    Block #24: executed      0 time(s) address= 0x44ac function= test1 line= 128 file= test1.c
    Block #25: executed   2599 time(s) address= 0x44c0 function= test1 line= 128 file= test1.c
    Block #26: executed      0 time(s) address= 0x4504 function= test1 line= 128 file= test1.c
    Block #27: executed   2599 time(s) address= 0x4518 function= test1 line= 128 file= test1.c
    Block #28: executed   1288 time(s) address= 0x4560 function= test1 line= 131 file= test1.c
    Block #29: executed   1220 time(s) address= 0x458c function= test1 line= 131 file= test1.c
    Block #30: executed   2599 time(s) address= 0x45a0 function= test1 line= 131 file= test1.c
    Block #31: executed   2599 time(s) address= 0x45d0 function= test1 line= 144 file= test1.c

--- remainder of bb.out deleted ---

This is a summary of all of the lines marked as being executed 0 times
by bb.out, in test1.c.

>From the initialization section immediately after function entry and
declaration blocks:

Block # 2: executed      0 time(s) address= 0x40e4 function= test1 line=  96 file= test1.c
Block # 4: executed      0 time(s) address= 0x4134 function= test1 line=  97 file= test1.c
   94    count1 = 0;
   95    count2 = 0;
   96    Bin1 = Mxsum/64;
   97    Bin2 = Mxsum/32;
   98

>From the calculation of the returned structure, immediately before the return:

Block #20: executed      0 time(s) address= 0x43ec function= test1 line= 127 file= test1.c
Block #22: executed      0 time(s) address= 0x4444 function= test1 line= 127 file= test1.c
Block #24: executed      0 time(s) address= 0x44ac function= test1 line= 128 file= test1.c
Block #26: executed      0 time(s) address= 0x4504 function= test1 line= 128 file= test1.c
   126
   127    count1 = Diff11 + (Diff12 * (Mxsum % 64))/64;
   128    count2 = Diff21 + (Diff22 * (Mxsum % 32))/32;
   129

--------------------------------------------------------------------------
Technical Details
Message-ID: <9601021926.AA00392@vaughn.physio-control>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,92edf3b90703b2bb
X-Google-Attributes: gid11318c,public
From: james@physio-control.com (James Taylor)
Subject: Profiling data from gcc/g++
Date: 1996/01/02
Message-ID: <9601021926.AA00392@vaughn.physio-control>
X-Deja-AN: 133736002
distribution: gnu
sender: daemon@cis.ohio-state.edu
organization: GNUs Not Usenet
newsgroups: gnu.gcc.help