This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fw: Questions on -ftest-coverage and gcov



Hi Chris,

Have you looked into gcov.v (and other gcov* files)?
I think that can help you to figure out things...

For example (quoted from gcov.c). Deeper look can answer your 4th question:
/* The bbg file is generated by -ftest-coverage option. The da file is
   generated by a program compiled with -fprofile-arcs. Their formats
   are documented in gcov-io.h.  */

Good luck,
Tehila.



                                                                       
             linuxkaffee@gmx.n                                         
             et                                                        
             Sent by:                                                   To
             gcc-owner@gcc.gnu         gcc@gcc.gnu.org                 
             .org                                                       cc
                                                                       
                                                                   Subject
             10/12/06 14:50            Questions on -ftest-coverage and
                                       gcov                            
                                                                       
                                                                       
                                                                       
                                                                       
                                                                       
                                                                       




Hi,

I've spent couple of hours reading the gcov manual and running
it with some examples. There are some questions that came up:

1) What exactly happens when gcc is invoked with "-ftest-coverage"?
The manual says that basically a program flow graph is constructed
in order to enable the assignment of profiling information
to the corresponding program parts. How does the flow graph looks
like in the .gcno file? Is it a low-level representation of the
program consisting of basic blocks combined via edges? If so, this
means that gcc transforms the (here) C source code to an intermediate
representation (I suppose RTL), right?

2) How are the line numbers mapped to the corresponding basic
blocks in the .gcno file? Is gcc proceeding each C statement in the
source code and generates the corresponding low-level (RTL)
code and when it notices that a new basic block is required, it
takes the source code line number and assigns it to the currently
proceeding basic block?

3) Question on an concrete example:
This is the analysed source code listed on the gcov man pages.

        -:    0:Source:tmp.c
        -:    0:Graph:tmp.gcno
        -:    0:Data:tmp.gcda
        -:    0:Runs:1
        -:    0:Programs:1
        -:    1:#include <stdio.h>
        -:    2:
        -:    3:int
        -:    4:main (void)
function main called 1 returned 100% blocks executed 75%
        1:    5:{
        1:    6:  int i, total;
        -:    7:
        1:    8:  total = 0;
        -:    9:
       11:   10:  for (i = 0;
        1:   10-block  0
       11:   10-block  1
       10:   10-block  2
        -:   11:      i < 10;
        -:   12:      i++)
       10:   13:    total += i;
        -:   14:
             ...
        1:   19-block  0
        -:   20:}

I don't understand the annotations in line 10 that represent a for
loop. (On purpose, I've written the for-loop statements in separate
lines.) The statement "i=0" is executed once and belongs to the
block that also contains code from line 6-9. That's OK. Then,
the exit test "i<10" is executed which should be placed in a new
basic block to be able to jump to it. (I've verified this by
looking at the generated assembly code.) However, the corresponding
annotations "block 1" are placed before line 11. Why? Same for the
following two statements "i++" and "total += i" that are also
placed in the a separate basic block (in the generated assembly file).
Also here, the annotations "block 2" are placed before the corresponding
source code lines 12 and 13. Can you explain this to me?

4) In general, where can I find the source code for work done
when gcc is invoked with "-ftest-coverage" and "-fprofile-arcs".
I've downloaded the gcc v4.1 source code from gcc.gnu.org and
grep'ed for "ftest-coverage" but found merely gcc.c containing
this string. However, in gcc.c the flow graph (mentioned in 1))
is not reconstructed.

Thank you very much for your help.

Best regards,
Chris
--
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]