gcov not generating .gcda file

View: New views
4 Messages — Rating Filter:   Alert me  

gcov not generating .gcda file

by hmiller :: Rate this Message:

| View Threaded | Show Only this Message

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


Re: gcov not generating .gcda file

by Andi Hellmund :: Rate this Message:

| View Threaded | Show Only this Message

Hey,

> 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?

> 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




Parent Message unknown Re: gcov not generating .gcda file

by Andi Hellmund :: Rate this Message:

| View Threaded | Show Only this Message

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

Re: gcov not generating .gcda file

by Ian Lance Taylor-3 :: Rate this Message:

| View Threaded | Show Only this Message

Andi Hellmund <mail@...> writes:

> 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