<div dir="auto">Thought this was interesting. At least this info is now in the RTEMS archives.</div><br><div class="gmail_quote"><div dir="ltr">---------- Forwarded message ---------<br>From: <strong class="gmail_sendername" dir="auto">Jim Wilson</strong> <span dir="ltr"><<a href="mailto:jimw@sifive.com">jimw@sifive.com</a>></span><br>Date: Thu, Aug 9, 2018, 1:26 PM<br>Subject: Re: gcov questions<br>To: <a href="mailto:daro_ox@o2.pl">daro_ox@o2.pl</a> <<a href="mailto:daro_ox@o2.pl">daro_ox@o2.pl</a>>, <a href="mailto:gcc@gcc.gnu.org">gcc@gcc.gnu.org</a> <<a href="mailto:gcc@gcc.gnu.org">gcc@gcc.gnu.org</a>><br></div><br><br>On 08/09/2018 02:38 AM, <a href="mailto:daro_ox@o2.pl" target="_blank" rel="noreferrer">daro_ox@o2.pl</a> wrote:<br>
> Hello, I wanted to ask what model for<br>
> branch coverage does gcov use?<br>
<br>
There is a comment at the start of gcc/profile.c that gives some details <br>
on how it works. It is computing execution counts for edges in the <br>
control flow graph. As for which edges get instrumented, basically, you <br>
construct a control flow graph, create a minimal spanning tree to cover <br>
the graph, and then you only need to instrument the edges not on the <br>
spanning tree, plus the function entry point. You can compute the rest <br>
of the edge counts from that. Then there are some tricks to improve <br>
efficiency by putting frequently executed edges on the minimal spanning <br>
tree, so that infrequently edges get instrumented.<br>
<br>
Gcov was originally written in 1990, based on an idea that came from <br>
Knuth's Art of Computer Programming. Ball & Larus wrote a nice paper in <br>
1994 that does a good job of covering the methods used, though they may <br>
not have been aware of gcov at the time as it hadn't been accepted into <br>
GCC yet. This is "Optimally Profiling and Tracing Programs" TOPLAS July <br>
1994. I don't know if there are free copies of that available. There <br>
may be better references available now, as these techniques are pretty <br>
widely known nowadays<br>
<br>
Jim<br>
</div>