Invalid Clang Code Output

So I checked and assembled 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: ... unexpected end of file reached."

Now I am stuck and come to SO to seek help :)

I work with Ubuntu 13.04 and write in C ++ 11, just in case something changes.

+5
source share
2 answers

I had the same problem with clang with lcov on Ubuntu 13.04. Here is a solution that worked for me on several Ubuntu settings.

  • You will find two versions of gcov on Ubuntu. gcov-4.6.4 and gcov-4.7.3. By default, the gcov link is set to gcov-4.7.3. Change it to gcov-4.6.4
  • Also, use lcov version 1.10 instead of what is available with apt-get install

This should generate a code coverage report.

EDIT: Mine is an update from Ubuntu 12.04 to 13.04. Just in case, you do not see two versions of gcov.

+2
source

Just summarize the steps for the answer @Himanshu already shared in case someone is looking for the exact steps to do this:

Install gcc 4.6

sudo apt-get-install -y gcc-4.6

I could not find locv version 1.10 out of the box, so I compiled it myself:

git clone https://github.com/linux-test-project/lcov.git

cd lcov

Switch to a new branch with a commit that posted lcov 1.10 as a base

git checkout -b 1_10 b5c1bdd

Compile lcov

sudo make install

Make sure lcov 1.10 is installed

lcov --version

Given all these things, use the command:

lcov --gcov-tool /usr/bin/gcov-4.6 --capture -d gcov_data/ -o gcov_data/coverage.info

This avoids working with the default gcov in the system.

Then generate a visual coverage file

genhtml -o gcov_data/html gcov_data/coverage.info

where gcov_data is the folder containing the gcno and gcda .

0
source

Source: https://habr.com/ru/post/1492417/


All Articles