gcov and autotools - filename issues

Adam Nielsen a.nielsen@shikadi.net
Sat Apr 10 05:59:00 GMT 2010

>>   $ gcov tests/tests.cpp
>>   tests.gcno:cannot open graph file
>> Which is correct, because the autotools name it as tests/tests-tests.gcno.
>> Likewise all the other .gcno files are in subdirectories with the directory
>> name prepended onto the filename.
> http://gcc.gnu.org/onlinedocs/gcc-4.4.3/gcc/Invoking-Gcov.html
> Note the -o option.

I had a look at the -o option, but I'm not sure how to use it.  For example,
this is the only way I can get gcov to run:

  $ gcov tests/tests.cpp -o tests/tests-tests

But then it produces tests.cpp.gcov that contains a bunch of lines like this:

        -:    1:/*EOF*/
        -:    2:/*EOF*/
        -:    3:/*EOF*/
        -:    4:/*EOF*/
        -:    5:/*EOF*/
        -:    6:/*EOF*/
        -:    7:/*EOF*/
        -:    8:/*EOF*/

I'm also a bit confused about why I should supply a .cpp filename instead of a
program name.  How does it know which program to run?  If I run "gcov
string.cpp" how does gcov know that it needs to run some other program with
certain parameters to actually execute the code in that file?


More information about the Gcc-help mailing list