GCov and GCC, *.da Files Not Created
I am using GCC version 3.3.6. When I instrument my object files with -fprofile-arcs
and -ftest-coverage
, the appropriate *.bb
and *.bbg
files are created.
The object files are then linked together into a static library l开发者_运维百科ibfoo.a
with:
ar rcs libfoo.a foo1.o foo2.o
.
Finally, a series of static libraries are linked together to create my executable with:
gcc -fprofile-arcs -o foo.o <static libraries linked all>
Now, when I run the image, the *.da files are not getting created. Is there a step that I am missing? Does anyone have any other suggestions?
Thanks.
The executable needs to be linked with the gcov library:
gcc -fprofile-arcs -o foo.o <static libraries linked all> -lgcov
EDIT: Starting from gcc 4.1.2, the --coverage
option can be used as a synonym for -fprofile-arcs -ftest-coverage
(when compiling) and -lgcov
(when linking).
Also, it is worth noting the files are created in the same directory as the compilation. This directory shall be reachable from the execution environment. Recent versions of gcc (4-1) introduced environment variables to tune the target directory : GCOV_PREFIX and GCOV_PREFIX_STRIP, see the cross-profiling section of gcc doc.
精彩评论