Discussion:
gcov not generating .gcda file
h***@hiwaay.net
2010-06-11 17:36:50 UTC
Permalink
I was doing some coverage testing today using gcov and gcc (4.1.2 on
Linux), and for some reason, the .gcda files quit getting generated.

What can cause this?

There are no other errors. The tests run fine and give the correct
results. This was working before.

Thanks,
Herb Miller
Andi Hellmund
2010-06-12 08:43:20 UTC
Permalink
Hey,
Post by h***@hiwaay.net
I was doing some coverage testing today using gcov and gcc (4.1.2 on
Linux), and for some reason, the .gcda files quit getting generated.
When saying quit generating: don't you get any .gcda file or are there
just a few files missing beginning from a certain point of time?
Post by h***@hiwaay.net
There are no other errors. The tests run fine and give the correct
results. This was working before.
Were there any changes to your environment since this was working the last
time? Did you update the gcc/gcov version? Did you possibly make any
changes to your build infrastructure?

When compiling your code with the special gcov options (-fprofile-arcs
-ftest-coverage), do you have a .gcno file for each source file or are
there possibly missing some .gcno files as well?

Andi
Andi Hellmund
2010-06-23 22:11:04 UTC
Permalink
Hey Herb,

sorry for the late response.
I do get .gcno files.
Right, these files get generated by the compiler if you specify the
-ftest-coverage option (or the --coverage option). The *.gcno files will
the be used to calcuate the program coverage by gcov.
Is theer some sort of a log file some where that may give me an idea
what is happening?
I shortly checked the code of libgcov.a and I could not find any log
entries. So, if you really want to debug the libgcov.a (which gets
linked into your app whenever you build with -fprofile-arcs) you would
apparently have to modify the code of libgcov.a.

But, while playing around with the -fprofile-arcs and -ftest-coverage
options, I realized that the *.gcda don't necessarily get created in
your current work directory. The file path for the *.gcda file gets
included hard-coded as absolute file name into the executable.

For example, taking this sample test program 'test.exe', you could
display the file paths by using:

# strings test.exe | grep gcda
/home/andi/Development/gcov/test.gcda

I don't want to say that this is the solution for your problem, but
maybe you looked in the wrong directories?

Unfortunately, I can't find any option which tells gcc to write a
relative path into the exectuable, but I would say it should be quite
easy to add a patch for that (assuming this solves your problem)

I hope that helps,
Andi
Ian Lance Taylor
2010-06-24 04:49:47 UTC
Permalink
Post by Andi Hellmund
Unfortunately, I can't find any option which tells gcc to write a
relative path into the exectuable, but I would say it should be quite
easy to add a patch for that (assuming this solves your problem)
Or see the environment variables GCOV_PREFIX and GCOV_PREFIX_SPLIT.

http://gcc.gnu.org/onlinedocs/gcc-4.5.0/gcc/Cross_002dprofiling.html

Ian

Loading...