Source code coverage of gcc

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Source code coverage of gcc

sameeran joshi
Hi,
I have a random C program as a test case, for which I need to do
source code coverage on gcc.
I have used the gcov tool and further the lcov tool. The percentage of
source code coverage which I get after using gcov, Is that the final %
which I need to do gcc source code coverage?

What does it mean to build gcc with -pg option, how does that help in
source code coverage?

Thanks,
Sameeran Joshi
Reply | Threaded
Open this post in threaded view
|

Re: Source code coverage of gcc

Andi Kleen-5
sameeran joshi <[hidden email]> writes:

> Hi,
> I have a random C program as a test case, for which I need to do
> source code coverage on gcc.
> I have used the gcov tool and further the lcov tool. The percentage of
> source code coverage which I get after using gcov, Is that the final %
> which I need to do gcc source code coverage?
>
> What does it mean to build gcc with -pg option, how does that help in
> source code coverage?

lcov/gcov can only work if the code is instrumented.
So this requires building gcc with BOOT_CFLAGS="-O2 -g -pg"
(see the chapter on building gcc in the manual for more information)

You would then run the instrumented gcc, which writes coverage
data to disk. Then lcov can be used to get a summary of coverage.

-Andi