<s>
Gcov	B-Application
is	O
a	O
source	B-Application
code	I-Application
coverage	I-Application
analysis	O
and	O
statement-by-statement	O
profiling	O
tool	O
.	O
</s>
<s>
Gcov	B-Application
generates	O
exact	O
counts	O
of	O
the	O
number	O
of	O
times	O
each	O
statement	O
in	O
a	O
program	B-Language
is	O
executed	O
and	O
annotates	O
source	O
code	O
to	O
add	O
instrumentation	O
.	O
</s>
<s>
Gcov	B-Application
comes	O
as	O
a	O
standard	O
utility	O
with	O
the	O
GNU	B-Application
Compiler	I-Application
Collection	I-Application
(	O
GCC	B-Application
)	O
suite	O
.	O
</s>
<s>
The	O
gcov	B-Application
utility	O
gives	O
information	O
on	O
how	O
often	O
a	O
program	B-Language
executes	O
segments	O
of	O
code	O
.	O
</s>
<s>
The	O
gcov	B-Application
utility	O
does	O
not	O
produce	O
any	O
time-based	O
data	O
and	O
works	O
only	O
on	O
code	O
compiled	O
with	O
the	O
GCC	B-Application
suite	O
.	O
</s>
<s>
The	O
manual	O
claims	O
it	O
is	O
not	O
compatible	O
with	O
any	O
other	O
profiling	O
or	O
test	O
coverage	O
mechanism	O
,	O
but	O
it	O
works	O
with	O
llvm-generated	O
files	O
too	O
.	O
</s>
<s>
gcov	B-Application
produces	O
a	O
test	O
coverage	O
analysis	O
of	O
a	O
specially	O
instrumented	O
program	B-Language
.	O
</s>
<s>
The	O
options	O
-fprofile-arcs	O
-ftest-coverage	O
should	O
be	O
used	O
to	O
compile	O
the	O
program	B-Language
for	O
coverage	O
analysis	O
(	O
first	O
option	O
to	O
record	O
branch	O
statistics	O
and	O
second	O
to	O
save	O
line	O
execution	O
count	O
)	O
;	O
-fprofile-arcs	O
should	O
also	O
be	O
used	O
to	O
link	O
the	O
program	B-Language
.	O
</s>
<s>
After	O
running	O
such	O
program	B-Language
will	O
create	O
several	O
files	O
with	O
"	O
.bb	O
"	O
"	O
.bbg	O
"	O
and	O
"	O
.da	O
"	O
extensions	O
(	O
suffixes	O
)	O
,	O
which	O
can	O
be	O
analysed	O
by	O
gcov	B-Application
.	O
</s>
<s>
gcov	B-Application
creates	O
a	O
logfile	O
called	O
sourcefile.gcov	O
which	O
indicates	O
how	O
many	O
times	O
each	O
line	O
of	O
a	O
source	O
file	O
sourcefile.c	O
has	O
executed	O
.	O
</s>
<s>
This	O
annotated	O
source	O
file	O
can	O
be	O
used	O
with	O
gprof	O
,	O
another	O
profiling	O
tool	O
,	O
to	O
extract	O
timing	O
information	O
about	O
the	O
program	B-Language
.	O
</s>
<s>
The	O
following	O
program	B-Language
,	O
written	O
in	O
C	B-Language
,	O
loops	B-General_Concept
over	O
the	O
integers	O
1	O
to	O
9	O
and	O
tests	O
their	O
divisibility	O
with	O
the	O
modulus	O
( %	O
)	O
operator	O
.	O
</s>
<s>
To	O
enable	O
coverage	B-Application
testing	I-Application
the	O
program	B-Language
must	O
be	O
compiled	O
with	O
the	O
following	O
options	O
:	O
</s>
<s>
where	O
cov.c	O
is	O
the	O
name	O
of	O
the	O
program	B-Application
file	I-Application
.	O
</s>
<s>
This	O
creates	O
an	O
instrumented	O
executable	B-Application
which	O
contains	O
additional	O
instructions	O
that	O
record	O
the	O
number	O
of	O
times	O
each	O
line	O
of	O
the	O
program	B-Language
is	O
executed	O
.	O
</s>
<s>
The	O
option	O
adds	O
instructions	O
for	O
counting	O
the	O
number	O
of	O
times	O
individual	O
lines	O
are	O
executed	O
,	O
while	O
incorporates	O
instrumentation	O
code	O
for	O
each	O
branch	O
of	O
the	O
program	B-Language
.	O
</s>
<s>
The	O
executable	B-Application
can	O
then	O
be	O
run	O
to	O
analyze	O
the	O
code	O
and	O
create	O
the	O
coverage	O
data	O
.	O
</s>
<s>
If	O
the	O
program	B-Language
execution	O
varies	O
based	O
on	O
the	O
input	O
parameters	O
or	O
data	O
,	O
it	O
can	O
be	O
run	O
multiple	O
times	O
and	O
the	O
results	O
will	O
accumulate	O
in	O
the	O
coverage	O
data	O
files	O
for	O
overall	O
analysis	O
.	O
</s>
<s>
This	O
data	O
can	O
be	O
analyzed	O
using	O
the	O
gcov	B-Application
command	O
and	O
the	O
name	O
of	O
a	O
source	O
file	O
:	O
</s>
<s>
The	O
gcov	B-Application
command	O
produces	O
an	O
annotated	O
version	O
of	O
the	O
original	O
source	O
file	O
,	O
with	O
the	O
file	O
extension	O
‘	O
.gcov	O
’	O
,	O
containing	O
counts	O
of	O
the	O
number	O
of	O
times	O
each	O
line	O
was	O
executed	O
:	O
</s>
<s>
Gcov	B-Application
command	O
line	O
utility	O
supports	O
following	O
options	O
while	O
generating	O
annotated	O
files	O
from	O
profile	O
data	O
:	O
</s>
<s>
-h	O
(	O
--help	O
)	O
:	O
Display	O
help	O
about	O
using	O
gcov	B-Application
(	O
on	O
the	O
standard	O
output	O
)	O
,	O
and	O
exit	O
without	O
doing	O
any	O
further	O
processing	O
.	O
</s>
<s>
-v	O
(	O
--version	O
)	O
:	O
Display	O
the	O
gcov	B-Application
version	O
number	O
(	O
on	O
the	O
standard	O
output	O
)	O
,	O
and	O
exit	O
without	O
doing	O
any	O
further	O
processing	O
.	O
</s>
<s>
Normally	O
gcov	B-Application
outputs	O
execution	O
counts	O
only	O
for	O
the	O
main	O
blocks	O
of	O
a	O
line	O
.	O
</s>
<s>
This	O
option	O
allows	O
you	O
to	O
see	O
how	O
often	O
each	O
branch	O
in	O
your	O
program	B-Language
was	O
taken	O
.	O
</s>
<s>
-c	O
(	O
--branch-counts	O
)	O
:	O
Write	O
branch	O
frequencies	O
as	O
the	O
number	O
of	O
branches	O
taken	O
,	O
rather	O
than	O
the	O
percentage	O
of	O
branches	O
taken	O
.	O
</s>
<s>
-n	O
(	O
--no-output	O
)	O
:	O
Do	O
not	O
create	O
the	O
gcov	B-Application
output	O
file	O
.	O
</s>
<s>
For	O
example	O
,	O
if	O
the	O
header	O
file	O
x.h	O
contains	O
code	O
,	O
and	O
was	O
included	O
in	O
the	O
file	O
a.c	O
,	O
then	O
running	O
gcov	B-Application
on	O
the	O
file	O
a.c	O
will	O
produce	O
an	O
output	O
file	O
called	O
a.c	O
#	O
#x	O
.h.gcov	O
instead	O
of	O
x.h.gcov	O
.	O
</s>
<s>
-p	O
(	O
--preserve-paths	O
)	O
:	O
Preserve	O
complete	O
path	O
information	O
in	O
the	O
names	O
of	O
generated	O
.gcov	O
files	O
.	O
</s>
<s>
-o	O
directory|file	O
(	O
--object-directory	O
directory	O
or	O
--object-file	O
file	O
)	O
:	O
Specify	O
either	O
the	O
directory	O
containing	O
the	O
gcov	B-Application
data	O
files	O
,	O
or	O
the	O
object	O
path	O
name	O
.	O
</s>
<s>
Lcov	O
is	O
a	O
graphical	B-Application
front-end	I-Application
for	O
gcov	B-Application
.	O
</s>
<s>
It	O
collects	O
gcov	B-Application
data	O
for	O
multiple	O
source	O
files	O
and	O
creates	O
HTML	B-Language
pages	O
containing	O
the	O
source	O
code	O
annotated	O
with	O
coverage	O
information	O
.	O
</s>
<s>
Lcov	O
supports	O
statement	O
,	O
function	O
,	O
and	O
branch	B-Application
coverage	I-Application
measurement	O
.	O
</s>
<s>
Gcovr	O
provides	O
a	O
utility	O
for	O
managing	O
the	O
use	O
of	O
gcov	B-Application
and	O
generating	O
summarized	O
code	B-Application
coverage	I-Application
results	O
.	O
</s>
<s>
Gcovr	O
produces	O
either	O
compact	O
human-readable	O
summary	O
reports	O
,	O
machine	O
readable	O
XML	O
reports	O
or	O
a	O
graphical	O
HTML	B-Language
summary	O
.	O
</s>
<s>
The	O
XML	O
reports	O
generated	O
by	O
gcovr	O
can	O
be	O
used	O
by	O
Jenkins	B-Language
to	O
provide	O
graphical	O
code	B-Application
coverage	I-Application
summaries	O
.	O
</s>
<s>
SCov	O
is	O
a	O
utility	O
that	O
processes	O
the	O
intermediate	O
text	O
format	O
generated	O
by	O
gcov	B-Application
(	O
using	O
gcov	B-Application
-i	O
)	O
to	O
generate	O
reports	O
on	O
code	B-Application
coverage	I-Application
.	O
</s>
<s>
These	O
reports	O
can	O
be	O
a	O
simple	O
text	O
report	O
,	O
or	O
HTML	B-Language
pages	O
with	O
more	O
detailed	O
reports	O
.	O
</s>
