I have a very simple example of using gcov:
library.cpp
file compiled and turned into library.a
main.cpp
file compiled into executable and uses library.a
All of this done via a simple bash script:
g++ -c library.cpp -Wall -fprofile-arcs -ftest-coverage -o library.o
ar rvs library.a library.o
g++ main.cpp -Wall -fprofile-arcs -ftest-coverage library.a -o main
Now at this point I have the folllowing files (ignoring source and build script):
library.o
library.gcno
library.a
main.cpp
main
main.gcno
So far so good. Now I run my main
executable, which creates:
main.gcda
library.gcda
Again all as expected. Now for the question - when I run gcov main.cpp
I don't get any gcov files for library.cpp. Is that expected?
Do I really need to call gcov
on every source file I may have at any point in time? Is there not a way to call the first source file i.e main.cpp
and have it produce coverage stats for each piece of source main
goes on to call?
I appear to get gcov files for a lot of core library code that main.cpp
uses without need to call them directly with gcov (ostream.gov, locale.gcov...) just not library.gcov
Normally you'd call gcov *.gcno
.