On 08/09/2018 02:38 AM, daro...@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

Reply via email to