Is there a way to focus lcov code coverage reports to just one or two directories?

I used the –no-external flag together with the –directory flag to exclude unwanted files. The definition of external from the man: External source files are files which are not located in one of the directories specified by –directory or –base-directory. So my command looked like this: $ lcov –directory src -c -o report.info –no-external Capturing … Read more

gcov: producing .gcda output from shared library?

I finally solved this problem by getting some help from the gcc guys. See the thread here: http://gcc.gnu.org/ml/gcc-help/2010-09/msg00130.html. It turns out that the .gcda files were being put in the .libs directory since that’s where the shared library (.so) files were. In order to get gcov to produce the output, I had to move the … Read more

Getting useful GCov results for header-only libraries

Apart from the usual flags to GCC controlling inlining; –coverage -fno-inline -fno-inline-small-functions -fno-default-inline You can instantiate your template classes at the top of your unit test files; template class std::map<std::string, std::string>; This will generate code for every method in that template class making the coverage tools work perfectly. Also, make sure that you initialise your … Read more

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)