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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With