public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Source code coverage of gcc
@ 2018-12-06 14:06 sameeran joshi
  2018-12-07  0:00 ` Andi Kleen
  0 siblings, 1 reply; 2+ messages in thread
From: sameeran joshi @ 2018-12-06 14:06 UTC (permalink / raw)
  To: gcc

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Source code coverage of gcc
  2018-12-06 14:06 Source code coverage of gcc sameeran joshi
@ 2018-12-07  0:00 ` Andi Kleen
  0 siblings, 0 replies; 2+ messages in thread
From: Andi Kleen @ 2018-12-07  0:00 UTC (permalink / raw)
  To: sameeran joshi; +Cc: gcc

sameeran joshi <gsocsameeran@gmail.com> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-12-07  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-06 14:06 Source code coverage of gcc sameeran joshi
2018-12-07  0:00 ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).