gcovr: RuntimeError: GCOV returncode was 5.
Problem
After executing the instrumented code gcovr -r . --html-details -o coverage/index.html
fails with no output from gcov
and a Python RuntimeError that says GCOV returncode was 5.
Solution 1
In one case a full clean of the relevant build directory and a rebuild and rerun was enough to fix the issue.
Added 2024-01-17
Solution 2
In another case the first solution was not enough. Rerunning gcovr with
--verbose prints the failing gcov command line and running the underlying gcov
command manually revealed that it was trying to process a .gcda file without a
corresponding .gcno file. In this case the offending file was part of a library
that was not interesting to include in the final report and adding the correct
--exclude-directories flag to gcovr solved the returncode 5 issue.
Added 2024-01-17