What is the branch in the destructor reported by gcov?

In a typical implementation the destructor usually has two branches: one for non-dynamic object destruction, another for dynamic object destruction. The selection of a specific branch is performed through a hidden boolean parameter passed to the destructor by the caller. It is usually passed through a register as either 0 or 1. I would guess … Read more

How do I tell gcov to ignore un-hittable lines of C++ code?

Please use lcov. It hides gcov’s complexity, produces nice output, allows detailed output per test, features easy file filtering and – ta-taa – line markers for already reviewed lines: From geninfo(1): The following markers are recognized by geninfo: LCOV_EXCL_LINE Lines containing this marker will be excluded. LCOV_EXCL_START Marks the beginning of an excluded section. The … Read more

How to resolve __gcov_init undefined reference issue when linking

Try this approach: Compile the code for which you want to generate the coverage with these options: CFLAGS: -fprofile-arcs -ftest-coverage LFLAGS: -lgcov –coverage If this doesn’t solve the problem, then please provide some information on the structure of your application, i.e. whether its single program or an application involving shared/static libraries etc.

Where are the gcov symbols?

I just spent an incredible amount of time debugging a very similar error. Here’s what I learned: You have to pass -fprofile-arcs -ftest-coverage when compiling. You have to pass -fprofile-arcs when linking. You can still get weird linker errors when linking. They’ll look like this: libname.a(objfile.o):(.ctors+0x0): undefined reference to ‘global constructors keyed to long_name_of_file_and_function’ This … Read more