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
2 answers

Run gcov tool using c++ compiler

I am working, for the first time, with the coverage tool gcov to analyze a large project. I have a directories structure like this: HW -FooHW1.cpp -FooHW1.h -FooHW2.cpp -FooHW2.h -... -Makefile.am Lib1 …
gRomano
  • 37
  • 1
  • 2
  • 4
3
votes
1 answer

gcov creates .gcov files in the current directory. Is there any way to change this?

I'm running gcov/gcc 4.1.2 on RHEL. When I want to specify a directory for the gcov files. Any ideas on how to do this?
Chip
  • 3,226
  • 23
  • 31
3
votes
1 answer

Dumping gcov data at runtime

I'm using gcov to collect code coverage data for a C project I'm working on. I understand that gcov dumps the code coverage data once the program exits after completion. How do I collect gcov data for long running processes. (say, my program is the…
Raj
  • 4,342
  • 9
  • 40
  • 45
3
votes
2 answers

gcov stopped to generate gcda file after added -rdynamic flag (__gcov_flush() called through gdb)

I've got some server in c++ (commands acquired from build-system): g++ -o obj/server.o -c -m64 -isystem/opt/boost/include -Wall -Werror -march=core2 -ftest-coverage -fprofile-arcs -DGCOV_ENABLED= -Iinclude -I/opt/hydraOST/lzopro/include…
ddzialak
  • 1,042
  • 7
  • 15
2
votes
1 answer

Gcovr branch coverage for simple case

I developed a simple example to test gcovr and gcov: #include int main (int argc, const char * argv[])…
Roman
  • 175
  • 2
  • 6
2
votes
0 answers

gcov to ignore standard library branch?

I'm trying to use gcov/lcov to generate a report for my test suites for my source code. Is there a way to tell gcov to ignore the branches incurred by standard libraries. For example, stringstream : 2 : …
2
votes
2 answers

Code Coverage GCov not working with XCode 4.2 and iOS SDK 5

I've been trying to get GCov working with Xcode 4.2Build 4D199 on Lion with iOS SDK 5.0 to no avail. Has anyone had any luck with this? I'm using Google Tools For Mac for my unit tests and I've linked in libprofile_rt.dylib and…
Cliff
  • 10,586
  • 7
  • 61
  • 102
2
votes
2 answers

Unable to generate *.c.gcov file

I have the following structure: Source_code/build/unix/Makefile Source_code/code/Lib/src/lib1/a.c The -fprofile-arcs and -ftest-coverage options are mentioned in the gcc compilation option. It successfully generates the a.gcda and a.gcno files. And…
2
votes
1 answer

Getting 0 gcov coverage for a mac app

I have done the following but I am still getting 0% gcov coverage for my .app. Here is what I am doing: I am using Xcode 3.2.6, GCC 4.2 and am on Mac OSX 10.6. I duplicated the Debug config and call it Gcov. In the Gcov config and the app target…
Lisa Young
  • 21
  • 3
2
votes
1 answer

lcov : coverage of source for several executions

I've created simple hello word cpp app. Compiled it by passing gcc --coverage flag Executed the executable Generated coverage by invoking lcov --directory . --capture --output-file ic.info Generated html based report by genhtml genhtml -o html/…
deimus
  • 9,565
  • 12
  • 63
  • 107
2
votes
1 answer

GCOV/LCOV ignores `used functions` declared before an `unused function`

The question may seem weird. I tried to use GCOV/LCOV for my small project and practiced with simple code before applying it. While practicing it, I encountered an error that I had no idea how to solve. The report created by LCOV showed that the…
2
votes
0 answers

Code coverage with clang-cl compiler using llvm-cov generates report with tests files coverage missing

I am trying to get code coverage for a c/c++ llvm-clang project in visual studio IDE which is compiled as a static library and I have a test project written using Gtest to test the static library containing different source files, I can generate a…
RODEB
  • 31
  • 1
2
votes
1 answer

CMake- what is the difference between 'target_link_options(.. -lgcov)' and 'target_link_libraries(...gcov)'?

I'm trying to build a library with code coverage enabled like so: add_library(my_library my_lib.cpp) target_compile_options(my_library PRIVATE --coverage) target_link_options(my_library PRIVATE -lgcov) and then later I have some tests…
emf
  • 23
  • 3
2
votes
1 answer

Why does GCOV claim this line is not covered?

I recently upgraded to a new version of gcc/g++/gcov, and now gcov behaves strangely. The new version claims some lines of code are not covered that were seen as covered by the old version. I managed to reduce my code to this minimal…
Filipp
  • 1,843
  • 12
  • 26
2
votes
1 answer

Using Gcov with CMake and Catch

I want to use Gcov to report coverage for my static library Catch test suite, compiled using CMake. . ├── CMakeLists.txt ├── bin ├── CMakeModules │   └── CodeCoverage.cmake ├── src │   ├── some_function.cpp │   ├── another_function.cpp │   └──…
Inigo Selwood
  • 822
  • 9
  • 20