Search code examples
c++clinuxgccgcov

gcov-tool merge: "not a gcov data file"


I'm trying to use gcov-tool to merge some existing coverage data (which I did not create myself) for several source files. But when I invoke gcov-tool merge dir1 dir2 where dir1 and dir2 are the directories containing the .gcda files which I intend to combine, I am instead confronted with ./SOME_FILE.gcda: not a gcov data file errors for each file in dir1.

At first I assumed that the coverage files must be corrupted but then I had a look at the gcc-6.3.0 (which matches the version of gcov-tool I have installed) source code (libgcc/libgcov-util.c) in which that error message seems to be printed only if the first few bytes of some .gcda file do not match the magic ASCII string 'gcda'. Yet hd dir1/SOME_FILE.gcda yields:

00000000 67 63 64 61 36 30 33 2a 17 68 64 3d 01 00 00 00 |gcda603*.hd=....|

and so on.

Has anyone dealt with something similar before?


Solution

  • I have figured it out, it was an endianness issue. I was looking at the wrong check inside the gcc code which actually tests for both little and big endian .gcda files. gcov-tool does not do this (which I find odd) so it seems you have to execute it on a machine with the same endianness as the one the coverage data was generated on.