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

C++ using GCOV/LCOV in a CMake project

I'm working in a C++ Project with a structure similiar to the following: --- /src |--comms |--utils |--interfaces … CMakeList.txt --- /test |---test1/ |--main.cpp …
Jupiter
  • 91
  • 1
  • 1
  • 4
9
votes
2 answers

Generating empty .gcda files

I use gcov for doing code coverage analysis with lcov for generating graphical output of coverage. This works well for code file where atleast some part of object file has been executed. I want to be able to track files which have not been executed…
mnair4
  • 93
  • 1
  • 4
9
votes
1 answer

Compiling googletest for gcov

I want to get coverage information from my googletest tests, but I'm having trouble finding good instructions. I presume I'm supposed to compile my gtest binary such that it spits out .gcno and .gcna files. However no combination of compiler flags…
jsj
  • 9,019
  • 17
  • 58
  • 103
9
votes
1 answer

Is there anyway to merge two gcov files into one

I am using gcov for coverage test in macosx platform. I finish the configuration for xcode by set: 1. Build Settings ==> Generate Test Coverage Files == Yes 2. Build Settings ==> Instrument Progaram Flow == Yes 3. Build Phases ==> Link Binary with…
jimwan
  • 1,086
  • 2
  • 24
  • 39
9
votes
2 answers

How does one get the actual function names from these output

I use boost test for unit testing and gcov and lcov for measuring the coverage. Unfortuanlly genhtml generates reports like that for function coverage: I now want to know what the function _ZN7UtilLib11ProgressBarC2EjdRSo actually is. So far I can…
tune2fs
  • 7,605
  • 5
  • 41
  • 57
8
votes
1 answer

CMake and lcov: gcno files not found

I am trying to get code coverage on my CMake based project (which consists of several targets). First I generate gcno files with: lcov -b . -d . -o coverage.output --capture --initial The *.gcno are generated…
Lars Bilke
  • 4,940
  • 6
  • 45
  • 63
8
votes
4 answers

How to do code coverage on embedded

I write a project for a non POSIX embedded system so I cannot use gcc option --coverage (i don't have read or write). What else can I do to produce gcov like output. I do have an output function.
Guy
  • 501
  • 2
  • 4
  • 13
8
votes
1 answer

How to force gcov to extract data, even when program is aborted

I'm using a test-generating tool called KLEE, that creates lots of tests for my C99-Code. Afterwards I run the tests and check line coverage with gcov. Gcov seems to update coverage data at the end of the run upon successful completion. However,…
Henning
  • 83
  • 1
  • 5
8
votes
3 answers

Finding non-instantiated templates in C++ code

What is the best way to find uninstantiated templates in C++ Code? I have a code base that heavily uses templates. Of course, we want to make sure that the test coverage is high. For all used code, this works very well using gcov. However, unused…
Manuel
  • 6,461
  • 7
  • 40
  • 54
8
votes
3 answers

C++ Using gcov and lcov problem?

I am using ubuntu 10.1, g++ compiler. I trying to use gcov and lcov for my C++ project. I manage to compile the gcov: g++ -fprofile-arcs -ftest-coverage main.cpp user.cpp game.cpp There is no error or warning message. Next I try to run gcov: gcov…
cpp_noob
  • 253
  • 2
  • 6
  • 12
8
votes
2 answers

iPhone: Cannot get simulator to generate .gcda profiling data files

I'm attempting to profile my code using the iPhone simulator. I've enabled Generate Test Coverage File and Instrument Program Flow and added -lgcov to the linker flags. According to everything I've read that should be all I need to do in terms of…
drekka
  • 20,957
  • 14
  • 79
  • 135
8
votes
2 answers

How to use gcov with Cmake

I'm having difficulties following this guide (that I've seen recommended on another post) on the matter https://github.com/bilke/cmake-modules/blob/master/CodeCoverage.cmake First: Copy this file into your cmake modules path. How do I know what my…
fedest
  • 1,190
  • 3
  • 15
  • 35
8
votes
1 answer

code coverage with visual studio and gtest

Has anyone ever used gtest with visual studio? if so, how did you get code coverage reports? I'd like to configure my project to produce coverage data, but it seems like nobody else uses gtest/visual studio with gcov or any other code coverage.
Jose Villalta
  • 1,457
  • 1
  • 12
  • 20
8
votes
3 answers

How do the code coverage options of GCC work?

Consider the following command: gcc -fprofile-arcs -ftest-coverage main.c It generates the file, main.gcda, which is to be used by gcov, to generate the coverage analysis. So how does main.gcda is generated? How the instrumentation is done? Can I…
Karthik
  • 365
  • 1
  • 3
  • 16
7
votes
1 answer

Understanding branches in gcov files

I'm trying to understand the output of the gcov tool. Running it with no options makes sense, but I'm wanting to try and understand the branch coverage options. Unfortunately it's hard to make sense of what the branches do and why they aren't taken.…
Martin Pilkington
  • 3,261
  • 22
  • 16