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

CMake/CTest & gcovr: filename extensions?

After compiling with CMake with flags --coverage, and running my boost unit test programs, files with extension .cpp.gcda and .cpp.gcno are created. If I then run gcovr it claims it cannot find the .gcno files (error message ".gcno:cannot open graph…
ikku100
  • 809
  • 1
  • 7
  • 16
5
votes
3 answers

lcov for multiple directories containing gcda files

I want to generate the coverage reports using gcov and lcov. What I have done till now:- 1. I compiled my code using --fprofile-arcs and -fprofile-coverage in g++. 2. I have linked using lcov. 3. I have .gcno files with th e.o location. 4. When I…
crazy_prog
  • 1,085
  • 5
  • 19
  • 34
4
votes
2 answers

No code coverage with Mac OS X Lion and XCode 4 / llvm-g++-4.2

Other people have reported not being able to generate code coverage with XCode 4, but I find not only can I not do it from within XCode 4, I can't do it even with a simple toy program from the command line. I followed the examples given here and…
Ben Hocking
  • 7,790
  • 5
  • 37
  • 52
4
votes
3 answers

Is it possible to exclude a redundant, invisible else branch with gcov?

Imagine the following function: int myFunction(my_enum_t x) { int result = 0; if ((x != ENUM_VAL_A) && (x != ENUM_VAL_B) && (x != ENUM_VAL_C)) { result = -1; } if (0 == result) { result = mutateSomething(x); } …
Walkingbeard
  • 590
  • 5
  • 15
4
votes
0 answers

genhtml: ERROR: cannot read path-to-file on Linux only

I generate lcov file and use genhtml to produce html report files using: genhtml out/cov.info -o out/temp On windows it works fine and the index.html is generated, while in Linux I get this error: Found 1 entries. Found common filename prefix…
Engineer
  • 75
  • 9
4
votes
0 answers

GCov showing closing braces as not executed

Having an issue with producing accurate gcov results, code is compiled with gcc (version 4.4.7) -g, no optimization. I'm getting accurate coverage on functions with the except of constructors CPPFLAGS += --coverage -O0 LDFLAGS += -lgcov…
4
votes
0 answers

Aggregate Initialization Branch Coverage

I am building a tool that is essentially an alternative to lcov. I am trying to make the default branch coverage it generates have as little noise as possible. One source of branch noise seems to be initializer lists: #include #include…
Gillespie
  • 5,780
  • 3
  • 32
  • 54
4
votes
2 answers

How do I get XCode4 to find libgcov.a

I've been building a static library to share between multiple iOS projects, and I want to use gcov (or any code coverage analysis tool) to tell me where I'm missing my tests. However, when I enable gcov by following these directions:…
Rob Booth
  • 1,792
  • 1
  • 11
  • 22
4
votes
2 answers

How to merge coverage reports?

I have a C program which I compile with -fprofile-arcs -ftest-coverage flags.Then I run the program on 5 different inputs, this will override the .gcda file and give me a combined report.But I want to have the coverage report of individual tests and…
VVish
  • 251
  • 4
  • 11
4
votes
1 answer

gcov-tool merge: "not a gcov data file"

I'm trying to use gcov-tool to merge some existing coverage data (which I did not create myself) for several source files. But when I invoke gcov-tool merge dir1 dir2 where dir1 and dir2 are the directories containing the .gcda files which I intend…
Peter
  • 2,919
  • 1
  • 16
  • 35
4
votes
6 answers

DOS to UNIX path substitution within a file

I have a file that contains this kind of paths: C:\bad\foo.c C:\good\foo.c C:\good\bar\foo.c C:\good\bar\[variable subdir count]\foo.c And I would like to get the following file: C:\bad\foo.c C:/good/foo.c C:/good/bar/foo.c C:/good/bar/[variable…
calandoa
  • 5,668
  • 2
  • 28
  • 25
4
votes
1 answer

How to specify .gcno and .gcda directory separately in Gcov?

I'm going to have multiple .gcda files in my project. One for each test case. Because gcov will merge .gcda for each test case execution, I move each .gcda file to a different directory. When calling gcov, I tried to specify .gcda…
AceVez
  • 291
  • 1
  • 5
  • 19
4
votes
1 answer

Wrapping open() for unit testing will make gcov not able to open gcda file

I am in the process of implementing using testing for some C program. For this purpose I am using GCC's -Wl,--wrap=open in order to mock stdlib's open() function and to check that it has been called with the correct options. When doing so however…
MicroJoe
  • 267
  • 3
  • 12
4
votes
1 answer

libgcov fork and exec hooks

My man page for gcc claims about the --coverage option: Also "fork" calls are detected and correctly handled (double counting will not happen). And I notice my /usr/lib/gcc/x86_64-linux-gnu/5.4.0/libgcov.a contains symbols __gcov_fork,…
aschepler
  • 70,891
  • 9
  • 107
  • 161
4
votes
1 answer

Can i use gcov for kernel modules without recompiling the whole kernel?

I have ubuntu OS and i installed gcov in it. I am able to use gcov for my c-program which is in user space and i am getting the desired results. When i want to use gcov for my .ko files(kernel space) i am getting an error. I googled and from the…