Fwd: gcov questions

Joel Sherrill joel at rtems.org
Thu Aug 9 18:59:57 UTC 2018


Thought this was interesting. At least this info is now in the RTEMS
archives.

---------- Forwarded message ---------
From: Jim Wilson <jimw at sifive.com>
Date: Thu, Aug 9, 2018, 1:26 PM
Subject: Re: gcov questions
To: daro_ox at o2.pl <daro_ox at o2.pl>, gcc at gcc.gnu.org <gcc at gcc.gnu.org>


On 08/09/2018 02:38 AM, daro_ox at o2.pl wrote:
> Hello,   I wanted to ask what model for
> branch coverage does gcov use?

There is a comment at the start of gcc/profile.c that gives some details
on how it works.  It is computing execution counts for edges in the
control flow graph.  As for which edges get instrumented, basically, you
construct a control flow graph, create a minimal spanning tree to cover
the graph, and then you only need to instrument the edges not on the
spanning tree, plus the function entry point.  You can compute the rest
of the edge counts from that.  Then there are some tricks to improve
efficiency by putting frequently executed edges on the minimal spanning
tree, so that infrequently edges get instrumented.

Gcov was originally written in 1990, based on an idea that came from
Knuth's Art of Computer Programming.  Ball & Larus wrote a nice paper in
1994 that does a good job of covering the methods used, though they may
not have been aware of gcov at the time as it hadn't been accepted into
GCC yet.  This is "Optimally Profiling and Tracing Programs" TOPLAS July
1994.  I don't know if there are free copies of that available.  There
may be better references available now, as these techniques are pretty
widely known nowadays

Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20180809/f03747f5/attachment.html>


More information about the devel mailing list