Is there a way to merge two .gcda files into one?

Viewed 6110

I have several unit tests for an application, each of which is capable of generating .gcda files. I would like to be able to generate unified .gcda files which represent the coverage of my test suite as a whole. There doesn't appear to be an easy way to do this, but I could be wrong, and that's why I'm asking.

With gcov, is it possible to merge to .gcda files? was previously asked and the solution was to convert to lcov .info files and merge that way. If possible, I would like the output of the merge operation to still be a single .gcda file so that I'm not forced to use lcov.

3 Answers

Gcov package comes with gcov-tool executable which is capable of merging gcda files:

gcov-tool merge dir1 dir2

(position of .gcda files within dirN must be identical). Resulting .gcda will be stored in the merged_profile directory (can be overriden with -o flag).

Gcov-tool is mainly meant to be used with series of .gcda files generated with GCOV_PREFIX or -fprofile-dir=XXX.%p.

Gcov-tool can merge only two profiles at a time but you can use a wrapper gcov-tool-many to circumvent this.

Related