⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gcov-data-files.html

📁 gcc手册
💻 HTML
字号:
<html lang="en">

<head>

<title>Using the GNU Compiler Collection (GCC)</title>

<meta http-equiv="Content-Type" content="text/html">

<meta name="description" content="Using the GNU Compiler Collection (GCC)">

<meta name="generator" content="makeinfo 4.3">

<link href="http://www.gnu.org/software/texinfo/" rel="generator-home">

<!--

Copyright &copy; 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,

1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.



   <p>Permission is granted to copy, distribute and/or modify this document

under the terms of the GNU Free Documentation License, Version 1.2 or

any later version published by the Free Software Foundation; with the

Invariant Sections being "GNU General Public License" and "Funding

Free Software", the Front-Cover texts being (a) (see below), and with

the Back-Cover Texts being (b) (see below).  A copy of the license is

included in the section entitled "GNU Free Documentation License".



   <p>(a) The FSF's Front-Cover Text is:



   <p>A GNU Manual



   <p>(b) The FSF's Back-Cover Text is:



   <p>You have freedom to copy and modify this GNU Manual, like GNU

     software.  Copies published by the Free Software Foundation raise

     funds for GNU development.-->

</head>

<body>

<div class="node">

<p>

Node:<a name="Gcov%20Data%20Files">Gcov Data Files</a>,

Previous:<a rel="previous" accesskey="p" href="Gcov-and-Optimization.html#Gcov%20and%20Optimization">Gcov and Optimization</a>,

Up:<a rel="up" accesskey="u" href="Gcov.html#Gcov">Gcov</a>

<hr><br>

</div>



<h3 class="section">Brief description of <code>gcov</code> data files</h3>



   <p><code>gcov</code> uses three files for doing profiling.  The names of these

files are derived from the original <em>source</em> file by substituting

the file suffix with either <code>.bb</code>, <code>.bbg</code>, or <code>.da</code>.  All

of these files are placed in the same directory as the source file, and

contain data stored in a platform-independent method.



   <p>The <code>.bb</code> and <code>.bbg</code> files are generated when the source file

is compiled with the GCC <code>-ftest-coverage</code> option.  The

<code>.bb</code> file contains a list of source files (including headers),

functions within those files, and line numbers corresponding to each

basic block in the source file.



   <p>The <code>.bb</code> file format consists of several lists of 4-byte integers

which correspond to the line numbers of each basic block in the file. 

Each list is terminated by a line number of 0.  A line number of

-1 is used to designate that the source file name (padded to a

4-byte boundary and followed by another -1) follows.  In

addition, a line number of -2 is used to designate that the name

of a function (also padded to a 4-byte boundary and followed by a

-2) follows.



   <p>The <code>.bbg</code> file is used to reconstruct the program flow graph for

the source file.  It contains a list of the program flow arcs (possible

branches taken from one basic block to another) for each function which,

in combination with the <code>.bb</code> file, enables gcov to reconstruct the

program flow.



   <p>In the <code>.bbg</code> file, the format is:

<pre class="smallexample">             name of function #0

             checksum of function #0

             number of basic blocks for function #0 (4-byte number)

             total number of arcs for function #0 (4-byte number)

             count of arcs in basic block #0 (4-byte number)

             destination basic block of arc #0 (4-byte number)

             flag bits (4-byte number)

             destination basic block of arc #1 (4-byte number)

             flag bits (4-byte number)

             ...

             destination basic block of arc #N (4-byte number)

             flag bits (4-byte number)

             count of arcs in basic block #1 (4-byte number)

             destination basic block of arc #0 (4-byte number)

             flag bits (4-byte number)

             ...

     </pre>



   <p>A -1 (stored as a 4-byte number) is used to separate each function's

list of basic blocks, and to verify that the file has been read

correctly.



   <p>The function name is stored as a -1 (4 bytes), the length (4 bytes),

the name itself (padded to 4-byte boundary) followed by a -1 (4 bytes).



   <p>The flags are defined as follows:

     <ul>

<li>bit0

On function spanning tree



     <li>bit1

Is a fake edge



     <li>bit2

Is the fall through edge from one block to its immediate successor.



     <li>bit3-bit31

For future expansion



   </ul>



   <p>The <code>.da</code> file is generated when a program containing object files

built with the GCC <code>-fprofile-arcs</code> option is executed.  A

separate <code>.da</code> file is created for each source file compiled with

this option, and the name of the <code>.da</code> file is stored as an

absolute pathname in the resulting object file.  This path name is

derived from the object file name by substituting a <code>.da</code> suffix.



   <p>The <code>.da</code> consists of one or more blocks with the following

structure:

<pre class="smallexample">             "magic" number -123 (4-byte number)

     	number of functions (4-byte number)

             length of the "extension block" in bytes

     	extension block (variable length)

       	name of function #0 (the same format as in .bbg file)

             checksum of function #0

     	number of instrumented arcs (4-byte number)

             count of arc #0 (8-byte number)

             count of arc #1 (8-byte number)

             ...

     	count of arc #M_0 (8-byte number)

       	name of function #1 (the same format as in .bbg file)

             checksum of function #1

     	...

     </pre>

   Multiple program runs might merge data into a single block, or might

append a new block. The current structure of the extension block is as

follows:

<pre class="smallexample">             number of instrumented arcs in whole program (4-byte number)

             sum all of instrumented arcs in whole program (8-byte number)

             maximal value of counter in whole program (8-byte number)

             number of instrumented arcs in the object file (4-byte number)

             sum all of instrumented arcs in the object file (8-byte number)

             maximal value of counter in the object file (8-byte number)

     </pre>



   <p>All three of these files use the functions in <code>gcov-io.h</code> to store

integers; the functions in this header provide a machine-independent

mechanism for storing and retrieving data from a stream.



   </body></html>



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -