gcov code coverage



$vi hey.c
$gcc -fprofile-arcs -ftest-coverage hey.c
$./a.out
Hey :)
$gcov hey.c
File 'hey.c'
Lines executed:100.00% of 3
hey.c:creating 'hey.c.gcov'

$cat hey.c.gcov
-: 0:Source:hey.c
-: 0:Graph:hey.gcno
-: 0:Data:hey.gcda
-: 0:Runs:1
-: 0:Programs:1
-: 1:#include
1: 2:main()
-: 3:{
1: 4:printf(" Hey :) n");
1: 5:}
$



The ".gcov" files can be examined using a normal editor. The first
column is the number of times that the line is executed. A decimal
number indicates the number of times that the line of code executes, a
'-' means that it is no code is generated for the line, and "#####"
indicates the generated code was not executed at all. To the right of
the first ':' is line number the remainder of the line is the source
code.

Reference/Source :
http://sourceware.org/ml/systemtap/2006-q1/msg00056.html
http://gcc.gnu.org/onlinedocs/gcc/Invoking-Gcov.html#Invoking-Gcov

 

Leave a Reply

Your email address will not be published. Required fields are marked *