Clang Code Coverage Invalid Output

2019-05-07 01:11发布

问题:

So I've checked out and built the clang trunk by following these instructions http://clang.llvm.org/get_started.html. I can build my binary with --coverage and run it to get the .gcno and .gcda files, but when I run lcov I get "GENINFO: ... reached unexpected end of file".

Now I'm stuck and came to SO to look for help :)

I'm working with Ubuntu 13.04 and writing c++11, just in case that makes a difference.

回答1:

I had the same problem with clang with lcov on Ubuntu 13.04. Here is the solution which worked for me on more than one Ubuntu setup.

  1. You will find there are two versions of gcov on Ubuntu. gcov-4.6.4 & gcov-4.7.3. By default the gcov link is set to gcov-4.7.3. Change that to gcov-4.6.4
  2. Furthermore, use lcov version 1.10 instead of what is available via apt-get install

This should generate the code coverage report.

EDIT: Mine was a upgrade from Ubuntu 12.04 to 13.04. Just in case you don't see two versions of gcov.