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
7
votes
3 answers

What are your tips for interpreting gcov output in order to improve coverage?

I'm successfully using gcov in my project: I can build my project with gcov flags: -fprofile-arcs -ftest-coverage I link with the -lgcov option I run my unit test program and lots of gcda and gcno files are produced. I run gcov lots of times and…
quamrana
  • 37,849
  • 12
  • 53
  • 71
7
votes
1 answer

constexpr constructor won't show coverage data

Today I was rewriting my matrix class to be constexpr. I have(had) 100% unit test coverage on this class but I noticed after I converted almost all functions to constexpr a part of the constructor is marked in the lcov as no longer covered at…
user2882307
7
votes
2 answers

Function coverage is lesser even with 100% code coverage when objects created in the stack

I'm analyzing my code with gcov. It says my code is 2 functions lesser when objects are created in the stack. But when I do new-delete 100% function coverage is achieved. Code: class Animal { public: Animal() { } virtual ~Animal() …
Sujith Gunawardhane
  • 1,251
  • 1
  • 10
  • 24
7
votes
1 answer

How to suppress inlining of templates with gcov

I'm using GCC 4.9 with GCOV to get code and branch coverage. However, the results for branch coverage are utterly useless for my C++ code. It seems GCC inlines templates despite using all -fno-*-inline flags I know of. Here is a small example…
neverlord
  • 890
  • 6
  • 12
7
votes
1 answer

gcov ignoring lines in source file

I'm using gcov to metric testing coverage on a c++ library I contribute to. For some reason, gcov isn't recognizing lines in many of the files as executable. Out of 160-some lines in a given file it'll say that 40 of them are executable. For…
Jake Fenton
  • 101
  • 3
7
votes
1 answer

Ignore or exclude code in external libraries with gcov

I am working on a project which uses a couple of boost libraries. When looking at our test reports, we have seen that test coverage information sometimes does fit to our source code. I was able to track it down to boost::range. I think it is because…
Jens
  • 9,058
  • 2
  • 26
  • 43
7
votes
0 answers

gcov + googletest: Coverage of conditionals for death tests

I am using googletest to test my C project. Now, I added gcov to check the coverage of the unit tests. This all works fine. When looking at the coverage of the Conditionals in my code, my coverage rate drops significantly. I analyzed the coverage…
lmNt
  • 3,822
  • 1
  • 16
  • 22
7
votes
2 answers

Why gcc 4.1 + gcov reports 100% branch coverage and newer (4.4, 4.6, 4.8) reports 50% for "p = new class;" line?

When gcc 4.1 (using gcov) next line: p = new Class; is reported as 100% branch coverage <-- THIS IS OK for me. Why using gcc 4.4 and higher same line is reportted as: [+ -] p = new Class; (50% branch coverage)... <-- THIS IS a problem for covering…
Santos Ramirez
  • 121
  • 1
  • 4
7
votes
2 answers

gcov not showing any coverage data

I am trying to use gcov on Linux(Ubuntu) to see frequency of execution for each line of source. I have added following flags to my gcc compiler and linker flags, CCFLAGS = -fprofile-arcs -ftest-coverage LDFLAGS = -fprofile-arcs -lgcov but after…
goldenmean
  • 18,376
  • 54
  • 154
  • 211
7
votes
5 answers

gcov not generating gcda files

I tried to run gcov with -fprofile-arcs & -ftest-coverage and nothing for linking. It was giving this error:- hidden symbol `__gcov_init' in /home/mojave/tools/gcc-4.4.1/amd64/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.4.1/libgcov.a(_gcov.o) is…
crazy_prog
  • 1,085
  • 5
  • 19
  • 34
6
votes
2 answers

Adding lcov to Hudson

rather new to Hudson here. I was wondering, how would one integrate lcov with it? How would I install the tarball into a Hudson job?
Apophenia Overload
  • 2,485
  • 3
  • 28
  • 46
6
votes
2 answers

Native Code coverage with android soong build system

I'm trying to generate code coverage report for my native components with AOSP source code using soong build system. I have extended aosp vhal but unit test cases are same as in below…
Pankaj
  • 2,115
  • 2
  • 19
  • 39
6
votes
3 answers

Using lcov with gcc-8

I am trying to determine my testcoverage. To do this I compile my program with a newer version of gcc: CC=/usr/local/gcc8/bin/gcc FC=/usr/local/gcc8/bin/gfortran ./configure.sh -external cmake -d After compiling this with the --coverage option I…
Stein
  • 3,179
  • 5
  • 27
  • 51
6
votes
1 answer

lcov marking lines with function declarations as reachable but not covered

I'm trying to use lcov (v1.13, on OS X, with clang as compiler) to generate code coverage for my test suite and I've hit one annoying problem that I don't know how to solve. There's a few similar questions on SO, but I couldn't find the solution to…
aldanor
  • 3,371
  • 2
  • 26
  • 26
6
votes
2 answers

How to use gcovr with source files outside the current/build/run directory?

mkdir -p /tmp/build && cd /tmp/build && mkdir -p /tmp/src && echo "int main(){return 0;}" > /tmp/src/prog.c && gcc --coverage -o prog /tmp/src/prog.c && ./prog && gcovr -v -r . will output an empty report. Scanning directory . for gcda/gcno…
not-a-user
  • 4,088
  • 3
  • 21
  • 37