Gcov Internals

Nathan Sidwell nathan@acm.org
Mon Mar 25 14:16:00 GMT 2019


On 3/22/19 7:58 AM, Sebastian Roland wrote:
> Hi,
> 
> I am currently trying to understand the internals of Gcov. Specifically 
> I am wondering of the following:
> 
> 1) Certain Basic Blocks are instrumented with counters that are 
> incremented during execution. During compilation a destructor is 
> registered that actually goes through a gcov_info struct and finds all 
> counters in the appropriate gcov_fn_info struct(s). My question is how 
> (and where in the source code) do the references to the various counters 
> are linked to the gcov_info struct?

gcc/coverage.c generates the increments and the spanning tree used to 
determine where to place them.
> 2) What exactly is the purpose of the constructor (__gcov_init()) and 
> where are the values of the passed gcov_info struct set (probably 
> related to 1)?

It's a global constructor, libgcc/libgcov-$something

natha

-- 
Nathan Sidwell



More information about the Gcc mailing list