.gcda is not generated by the compiler; it is generated by your program when it is executed.
.gcno is a file generated at compile time, and it is a βnotes fileβ. gcc generates a notes file for the main unit (.gcno) for each control unit (compiler unit).
So how is main.gcda generated?
During operation, statistics are collected and stored in memory. Some output feedback is registered and called to write data to the .gcda file when the program exits. This means that if you call abort () instead of exit () in your program, the .gcda file will not be created.
How is measuring equipment manufactured? Can I see the tool code?
You need to check the gcc implementation to get the details, but basically the toolkit is done by inserting the instruction into the program to count the number of times each instruction is executed. But you donβt really need to keep a counter for each instruction; GCC uses some algorithm to generate a program flow graph and finds a spanning tree for the graph. You only need to equip some special arcs, and from them you can create coverage for all branches of the code. You can parse the binary to see the tool code. And here are some files to cover if you want to look at the gcc source file:
toplev.c coverage.c profile.c libgcov.c gcov.c gcov-io.c
edit: some known gcov FYI errors:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49484
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28441
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44779
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7970
source share