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
4
votes
0 answers

CMake + Jenkins for code coverage of untested file

I am looking for a solution to have a code coverage statistics among all C source file compiled in one cmake project and published under Jenkins. I use CMake 2.8.9, gcovr 3.1, Jenkins 1.564 and tried many different version of gcc/gcov (4.7.2 and >=…
4
votes
1 answer

xcodebuild gives “profiling: invalid magic number”, doesn't generate coverage files

Let's get this out of the way first: This question is not a duplicate of this earlier question. I'll explain why below. I'm running the command xcodebuild test -scheme 'ISO8601ForCocoa' SYMROOT=../build, and here's the output: Executed 16 tests,…
Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
4
votes
0 answers

LCOV code coverage - Exit status 255

When i run the code coverage to output in html, I get the error message: CalledProcessError: Command 'lcov -r mycoverage.2.temp "/../generated/*" -o mycoverage.2' returned non-zero exit status 255 The gcov -v gives: gcov (GCC) 3.4.2 I tried to find…
user1400995
4
votes
0 answers

Why aren't scopes that throw exceptions showing as covered in gcov/CoverStory?

I'm using the coverage tools in Xcode 4.6 and visualizing with CoverStory. No matter what I do, CoverStory never shows scopes in which I throw Objective-C exceptions as being covered, even though, when running the Unit Tests with breakpoints on…
ipmcc
  • 29,581
  • 5
  • 84
  • 147
4
votes
1 answer

Is it possible code coverage of a shared library using gcov?

I try to test an executable which uses OpenCV shared library. When using gcov to know what code lines were covered I only get info about my .cpp files and .hpp of the library. No info is shown about .cpp files of the library. I compiled and linked…
manmak
  • 43
  • 1
  • 3
4
votes
0 answers

How to use gcov with gcc without the optimization?

I have a test code like this: int diff21(int n) { if (n <= 21) { return 21 - n; } else { return (n - 21) * 2; } } and I added the compile flags: -fprofile-arcs -ftest-coverage to provide coverage data. I…
shengy
  • 9,461
  • 4
  • 37
  • 61
3
votes
3 answers

Why does gcov report 0% coverage on a header file for a well used class?

I'm attempting to measure test coverage for the first time using gcov. Now that I'm past the initial learning curve, things seem to be going well, except for one little snag. I expect that it boils down to a lack of understanding on my part, so…
Bill B
  • 1,280
  • 13
  • 16
3
votes
1 answer

libgcov profiling error - overwriting an existing profile data with a different timestamp

My issue is different than this question: the problem there was that he was compiling the same file twice. I am only compiling each file once. g++ -c "file_1.c" -o file_1.o -fprofile-arcs -ftest-coverage g++ -c "file_2.c" -o file_2.o …
Bob
  • 4,576
  • 7
  • 39
  • 107
3
votes
1 answer

On `gcc` 11, how to change the prefix of `.gcno` files when using `--coverage` so they match what `gcov` expects?

I'm adding code coverage on a C project of mine. The process I'm following is this: # compile a .c file, expecting two new files "a.out" and "main.gcno" gcc --coverage main.c # run executable to get coverage data, expecting to create a new…
TomTsagk
  • 1,474
  • 9
  • 23
3
votes
2 answers

Linux kernel 5.4 GCC 9.1.0 does not show code coverage

we are using Linux kernel 5.4 with gcc 9.1.0 on different architectures (arm, arm64, x86_64). I am in charge of creating code coverage for kernel modules. I am not selecting the Linux kernel version nor the compiler version. I am able to create code…
3
votes
1 answer

gcov not generating gcda file

Note: this could be considered as a duplicate of Gcov is not generating *.gcda file, however : This question has no answer I don't think the OP has the same system than me, so I don't think it'll be ok for me to just go and edit his question.…
Ablia
  • 191
  • 2
  • 10
3
votes
1 answer

Measuring coverage of C library called in python process

Let me start with the example - calling library code from python. This is the library code (compiled into library libfoolib): #include void bar() { printf("bar\n"); } void foo() { printf("foo\n"); } And this is the python code…
3
votes
4 answers

Core dump and gcov coverage report

I'm doing stress testing on multi-threaded program and collecting coverage as well. As far as I know, gcov doesn't produce .gcda files when program is terminated by _exit() or some signals such as SIGABRT, SIGSEGV and so on. When the program…
Doe
  • 141
  • 2
  • 4
3
votes
0 answers

gcov/lcov - How to exclude all but one directory from coverage data

I am creating code coverage reports for my C++ projects using gcov/lcov, and I am trying to remove all files except the ones in a certain directory from the coverage report (i.e. I do not want different dependencies in various folders to show up in…
pooya13
  • 2,060
  • 2
  • 23
  • 29
3
votes
2 answers

undefined reference to `__gcov_exit'?

while I am building glibc library using yocto project it is giving error: missing attribute ((constructor)) support?? after adding the coverage flags: TARGET_CFLAGS += "-fprofile-arcs -ftest-coverage" TARGET_LDFLAGS += "-lgcov -fprofile-arcs…
Ajay.kundu
  • 195
  • 2
  • 10