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
19
votes
1 answer

Can gcc/gcov be made to output coverage stats to a location other than the source folder?

When using gcc with -fprofile-arcs and -ftest-coverage, when the resulting executable terminates, it tries to create .gcda output files in the same location as the .o files used to compile the executable. This is inconvenient when I'm running on a…
kdt
  • 27,905
  • 33
  • 92
  • 139
18
votes
5 answers

gcov: cannot open graph file

I am trying to use gcov. I have this simple file a.c: int main() { return 0; } So I do gcc -fprofile-arcs -ftest-coverage a.c -o a ./a gcov a.c and I get a.gcno:cannot open graph file Am I doing something wrong? I'm under Mac OS X Lion.
Caleb Poucher
  • 181
  • 1
  • 1
  • 3
17
votes
5 answers

What's the best C++ code coverage tool that works with templates?

I have used gcov for testing code coverage, but when it comes to templated c++ code it doesn't work so well. I use boost::spirit extensively and gcov seems to simply ignore templated spirit code. Also I am wondering if there is a coverage tool to…
fantasticsid
  • 707
  • 8
  • 16
16
votes
4 answers

gcov with CMake using a separate build directory

I'm struggling to get coverage information for gcov. No errors during compilation and linking, but when I run the executable, no coverage data is produced. I'm using CMake with a separate build directory, passing flags to the compiler and linker in…
Bjoern
  • 169
  • 1
  • 1
  • 3
15
votes
5 answers

With gcov, is it possible to merge to .gcda files?

I have the same source files (C and Obj-C) being compiled into two targets: the unit test executable and the actual product (which then gets integration tested). The two targets build into different places, so the object files, .gcno and .gcda files…
Joe
  • 46,419
  • 33
  • 155
  • 245
15
votes
5 answers

Why doesn't gcov report any lines being covered by my unit tests?

I am using Xcode 3.2 on 10.6, with the shipped version of gcov and default GCC compiler (both version 4.2.1). I have created a dependent Cocoa unit test bundle which is injected into my app, and followed Apple's documentation on setting up a…
user23743
14
votes
1 answer

Excluding certain functions from gcov/lcov coverage results

Is it possible to exclude certain functions or lines of code from the gcov coverage analysis. My code contains certain functions that are used for debugging, and are not exercised as part of my test suite. Such functions reduce the coverage…
Buğra Gedik
  • 714
  • 8
  • 16
13
votes
1 answer

gcov produces different results on Clang and GCC

I'm trying to understand how to properly structure a C++ project by using CMake, googletest, and gcov for test coverage. I would like to build a general CMakeLists.txt that would work for any platform/compiler. This is my first attempt. However, if…
13
votes
2 answers

Looking for a way to exclude files used by geninfo/genhtml

We are trying to use geninfo and genhtml (alternative to gcovr, see here) to produce an html page using coverage provided by gcov. geninfo creates lcov-tracefiles from gcov's *.gcda files genhtml generates html files from the above…
Sagar
  • 9,456
  • 6
  • 54
  • 96
13
votes
3 answers

LCOV branches at the end of a function

What are the branches at the end of this function. How could I cover them?
jsj
  • 9,019
  • 17
  • 58
  • 103
12
votes
2 answers

Crossprofiling with gcov, but GCOV_PREFIX and GCOV_PREFIX_STRIP is ignored

I want to use GCOV to make code coverage but the tests will run on another machine. So the hard wired path to .gcda files in the executable won't work. In order to change this default directory I can use the GCOV_PREFIX and GCOV_PREFIX_STRIP env…
Calmarius
  • 18,570
  • 18
  • 110
  • 157
12
votes
1 answer

How do I tell lcov where to find my .cpp & .h files?

My source and build tree looks like this (see Makefile to put object files from source files different directories into a single, separate directory?) after a make (which builds and runs FooAndBarTests): src - Foo.cpp - Bar.cpp inc - Foo.h -…
Daryl Spitzer
  • 143,156
  • 76
  • 154
  • 173
12
votes
4 answers

gcov and switch statements

I'm running gcov over some C code with a switch statement. I've written test cases to cover every possible path through that switch statement, but it still reports a branch in the switch statement as not taken and less than 100% on the "Taken at…
Matt
  • 84,419
  • 25
  • 57
  • 67
12
votes
2 answers

"Hidden symbol `atexit' is referenced by DSO" when using libtool with gcov

I have a C++ project that uses the GNU Autotools for its build scripts and libtool for linking. Recently I have added code coverage instrumentation with gcov, by ensuring that GCOV_CFLAGS="-fprofile-arcs…
phs
  • 10,687
  • 4
  • 58
  • 84
11
votes
3 answers

Is it possible to measure function coverage with gcov?

Currently we use gcov with our testing suite for Linux C++ application and it does a good job at measuring line coverage. Can gcov produce function/method coverage report in addition to line coverage? Looking at the parameters gcov accepts I do not…
Dima Malenko
  • 2,805
  • 2
  • 27
  • 24
1
2
3
38 39