Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clang Code Coverage Invalid Output

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.

like image 507
RichardBruce Avatar asked Jul 20 '13 02:07

RichardBruce


People also ask

What is LCOV?

LCOV is a graphical tool for GCC's coverage testing with gcov. It creates HTML pages containing the source code annotated with coverage information by collecting gcov data from multiple source files. LCOV supports “Lines coverage” and “Functions coverage” measurement.

What is GCOV code coverage?

Gcov is a source code coverage analysis and statement-by-statement profiling tool. Gcov generates exact counts of the number of times each statement in a program is executed and annotates source code to add instrumentation. Gcov comes as a standard utility with the GNU Compiler Collection (GCC) suite.

What is region coverage?

Region coverage is the percentage of code regions which have been executed at least once. A code region may span multiple lines (e.g in a large function body with no control flow). However, it is also possible for a single line to contain multiple code regions (e.g in “return x || y && z”).

What is Clang LLVM?

Clang: a C language family frontend for LLVM. The Clang project provides a language front-end and tooling infrastructure for languages in the C language family (C, C++, Objective C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project.


1 Answers

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.

like image 134
Himanshu Avatar answered Oct 06 '22 14:10

Himanshu