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

Trouble running GCOV with multiple source files of the same name

According to GCC online docs, gcov should be run with the current directory the same as that when you invoked the compiler. Let’s say I have the following source files layout: -root -source -dir1 -file.cpp -dir2 …
Eric Z
  • 14,327
  • 7
  • 45
  • 69
3
votes
1 answer

How can we use gcovr with -g option?

How can we use gcovr with -g option? I've tried some commands but they all failed. I didn't get any errors but I didn't get the output that I've expected either. Documentation also does not give any examples: http://gcovr.com/guide.html Any ideas?…
leventunver
  • 3,269
  • 7
  • 24
  • 39
3
votes
0 answers

lcov appears to process .gcda files in a single process. I have many cores and I'd like to use them for this processing. How?

If I run: lcov --output-file $(BUILD_DIR)/coverage_all.info --capture --directory $(BUILD_DIR) It appears to process each .gcda file one at a time instead of taking advantage of all my cores. Is it possible to rewrite this step so that I can…
Mikey
  • 423
  • 1
  • 3
  • 9
3
votes
1 answer

GCOV Cross Profiling: __gcov_flush() does not flush coverage data for shared libraries

I am trying to get code coverage for an arm based embedded system. Using x86 for cross compilation.So basically, I have a cross profiling question. For the application I want to generate code coverage data, I have defined a signal handler inside…
utpal
  • 331
  • 5
  • 13
3
votes
0 answers

LCov - Found unrecognized record format errors

I've looking to get an HTML code coverage report working with an XCode 6.1 based project. My solution 'partially works', but I'm getting a lot of skipped files when running lcov: geninfo: file found unrecognized record format - skipping Some…
3
votes
2 answers

Is it possible to check if code coverage has increased after a test

I am analysing coverage of a large project using the coverage support in gcc with gcov. I am also running random tests to try and increase the coverage. Ideally, as I generate a test, I would like to save it if it increases any coverage metric.…
Dejan Jovanović
  • 2,085
  • 1
  • 16
  • 22
3
votes
1 answer

Why does gcov report in-class function definitions as not executable?

It seems like gcov does not report inline definitions of class methods as executable lines. Example: #include struct Foo { void bar() {} void baz() {} }; int main() { Foo foo; foo.bar(); } If I compile the above program with…
3
votes
0 answers

lcov and gcovr option for ignoring compiler generated dead code

My team is looking for a way to get around gcov reporting branch coverage for dead/compiler generated code. I noticed that gcovr has an option --exclude-unreachable-branches that seems to do what we need. Also, lcov has the option --no-markers which…
wizurd
  • 3,541
  • 3
  • 33
  • 50
3
votes
0 answers

Is it possible to get coverage statistics on C++ headers files with specialised templates in them?

I hope you can help. Ive have spend the day researching this problem and have yet to find a solution. I have a header file which contains specialized templates inside them and I would like to make sure my unit tests are covering it properly. I am…
Stoff81
  • 597
  • 4
  • 15
3
votes
3 answers

lcov not working properly for coverage

I am trying to get html coverage for a test using gcc 4.8.2 and lcov 1.10. I am sure that my source, objects and gcov files are at same place and that I'm running lcov from directory where I ran my compiler from as well. I'm getting the following…
risaldar
  • 71
  • 1
  • 2
  • 10
3
votes
1 answer

LCOV reports: 'geninfo: Negative length'

I'm analyzing C-Code with LCOV on two systems (windows 7, cygwin, Lcov 1.10). On one system I had never problems, but on the other with the same code I get: $ lcov --directory CMakeFiles/UnitTest.dir/main --capture --output-file lcov.log Capturing…
Led
  • 154
  • 1
  • 3
  • 12
3
votes
0 answers

C++ entire codebase coverage w/ gcov

We have a large body of C/C++ code that is cross-compiled for an embedded Linux target. We've recently begun implementing unit tests (using gmock/gtest) that are run on our development server (which is Linux as well). The unit tests are executed…
Curt C
  • 31
  • 1
3
votes
1 answer

No coverage when using gcov with child process and shared library

I am using gcov for a c++ test executable that spawns a child process. The child process contains a shared object library.The test process, child process, and the shared object library are all compiled in separate directories. I am using the…
wizurd
  • 3,541
  • 3
  • 33
  • 50
3
votes
2 answers

dlopen not working with code-coverage tools (lcov/gcov)

Structure of the entire application: Shared Library say - low_level.so. Static Library say - high_level.a. This static library uses the 'low_level.so' by calling the dlopen function (for loading the low_level.so) and dlsym function (for getting the…
Rajen
  • 931
  • 6
  • 8
3
votes
2 answers

interpret gcov output to identify basic blocks

I am using gcov with the option -a (--all-blocks) which from the manual: When you use the -a option, you will get individual block counts The original file: #include #include "file1.h" int max(int a , int b) { int k = 0; if (a > b) …
user847988
  • 984
  • 1
  • 16
  • 30