Questions tagged [gcov]

gcov is a code coverage tool for GCC

gcov allows you to analyze which parts of a program are not executed. This is interesting for example in order to know which part of a program are not tested. gcov also serves for profiling purposes.

gcov requires additional flags to be passed to GCC in order to generate a special version of a program. This version shouldn't be shipped because it is slower as it generates coverage data files.

575 questions
67
votes
8 answers

Where are the gcov symbols?

I'm trying to compile a simple app with gcov and getting the following link errors: gcc AllTests.o CuTestTest.o CuTest.o -o TestTest AllTests.o: In function `global constructors keyed to 0_RunAllTests': /home/p7539c/cutest/AllTests.c:26: undefined…
john146
  • 977
  • 2
  • 11
  • 15
58
votes
7 answers

How to resolve __gcov_init undefined reference issue when linking

I now work on C code coverage study and encountered following issue, GCC version 4.4.6: Added compiler flag CFLAGS = --coverage and linker option LDFLAGS := --coverage or LOCAL_LDLIBS := --coverage and got the error: undefined reference to…
lilingmzai
  • 601
  • 1
  • 5
  • 7
57
votes
4 answers

How do I tell gcov to ignore un-hittable lines of C++ code?

I'm using gcov to measure coverage in my C++ code. I'd like to get to 100% coverage, but am hampered by the fact that there are some lines of code that are theoretically un-hittable (methods that are required to be implemented but which are never…
jchl
  • 6,332
  • 4
  • 27
  • 51
41
votes
3 answers

What is the branch in the destructor reported by gcov?

When I use gcov to measure test coverage of C++ code it reports branches in destructors. struct Foo { virtual ~Foo() { } }; int main (int argc, char* argv[]) { Foo f; } When I run gcov with branch probabilities enabled (-b) I get…
Eddy Pronk
  • 6,527
  • 5
  • 33
  • 57
34
votes
4 answers

Getting useful GCov results for header-only libraries

For my header-only C++ library (lots of templates etc) I use GCov to check test coverage. However, it reports 100% coverage for all headers because the unused functions aren't generated by the compiler in the first place. Manually spotting uncovered…
pascal
  • 2,623
  • 2
  • 20
  • 30
33
votes
1 answer

gcov: producing .gcda output from shared library?

Is it possible to produce gcov data files (.gcda files) by running an executable linked to a shared library built with the --coverage option? Basically, I have the main library consisting of multiple c++ files compiled into one shared library and…
deuberger
  • 3,578
  • 6
  • 31
  • 33
32
votes
3 answers

Is there a way to focus lcov code coverage reports to just one or two directories?

I recently started using lcov to visualize my code coverage. It's a great tool. One thing I'm noticing is that it generates code coverage reports for all the files that I'm using - including those that I'm not interested in. For example, it will…
Runcible
  • 7,006
  • 12
  • 42
  • 62
28
votes
1 answer

In SonarQube what is the difference in meaning between the "Lines to Cover" and "Uncovered Lines" metrics?

I am looking at the Coverage report within the Measures tab of a SonarQube analysed C++ project. On that page my summary information is as follows: What are the differences between the "Lines to Cover" and "Uncovered Lines" metrics? I have looked…
TafT
  • 2,764
  • 6
  • 33
  • 51
28
votes
6 answers

LCOV/GCOV branch coverage with C++ producing branches all over the place

We are using LCOV/GCOV to produce test coverage of our projects. Recently we tried to enable branch-coverage additionally. But it looks like, this just doesn't yield the results we expected from a high-level developer view. Using branch-coverage…
Sven Eppler
  • 1,646
  • 1
  • 15
  • 26
28
votes
1 answer

GCOV: What is the difference between --coverage and --ftest-coverage when building with GCC?

Trying to get code coverage up and running, and I'm just reading documentation first. I found a few articles that mention building with the --coverage flag, while others mention the --ftest-coverage. Both descriptions seem to say they do the same…
user3338893
  • 917
  • 3
  • 10
  • 17
26
votes
1 answer

Is it possible to merge coverage data from two executables with gcov/gcovr?

On one project, I'm running the test cases on three different executables, compiled with different options. Depending on the options, some code paths are taken or not. Right now, I'm only using the coverage data from one executable. I'm using gcovr…
Baptiste Wicht
  • 7,472
  • 7
  • 45
  • 110
25
votes
4 answers

XCode 5.1 Unit Test Coverage Analysis Fails On Files Using Blocks

Today I was tasked with adding unit test coverage analysis to our code base. Today is also the day iOS 7.1 is released along with XCode 5.1. From the release notes: The gcov tool for code coverage testing has been reimplemented. The new version…
LeffelMania
  • 12,765
  • 4
  • 32
  • 34
24
votes
3 answers

gcov out of memory / mismatched version?

Just trying to get gcov up and running, getting the following error: $ gcov src/main.c -o build build/main.gcno:version '404*', prefer '407*' gcov: out of memory allocating 14819216480 bytes after a total of 135168 bytes I'm using clang/profile_rt…
Chris Bolton
  • 2,878
  • 6
  • 38
  • 57
22
votes
3 answers

Is code coverage already working for Swift?

I am trying to setup test code coverage for a Swift application on Xcode 6 Beta 4. I was able to do so in the past using ObjectiveC with Xcode 5, however I think I had to call the void __gcov_flush() method, to trigger generation of the .gcda/.gcno…
user3886079
  • 251
  • 2
  • 5
21
votes
1 answer

gcov warning: merge mismatch for summaries

Can anyone tell me what the gcov message "Merge mismatch for summaries" means? I have found the message in the gcc source here: http://www.opensource.apple.com/source/gcc/gcc-5646/gcc/libgcov.c It seems to be a sanity check that the tags in the…
mikelong
  • 3,694
  • 2
  • 35
  • 40
1
2 3
38 39