Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code coverage using gcov on parallel run

I have C/C++ code coverage setup with gcov for several files in the project. The executables are being run in parallel. This results in some shared piece of code to be run in parallel.

I am getting corrupt .da files or zero sized .da files. Is this a problem on parallel run?

Because two or more executable instance is trying to write on the same .da file for writing the coverage count for each statement in execution?

If so, is there any workaround?

Gcov version being used is 1.5

like image 238
Dr. Debasish Jana Avatar asked Feb 01 '13 09:02

Dr. Debasish Jana


1 Answers

I had a similar need and I solved it by setting up the GCOV_PREFIX environment variable.

According to the documentation:

GCOV_PREFIX contains the prefix to add to the absolute paths in the object file. Prefix can be absolute, or relative. The default is no prefix.

Setting GCOV_PREFIX to a custom directory, unique for each executable+execution, will force the runtime to generate '.gcda' in the specified directory instead of using the compilation one (where the '.gcno' are).

Once all the executions completed you'll be able to use them to generate the merged-run report.

like image 125
Adriano Avatar answered Oct 21 '22 00:10

Adriano