gcov

How to force gcov to extract data, even when program is aborted

久未见 提交于 2019-11-30 04:41:43
问题 I'm using a test-generating tool called KLEE, that creates lots of tests for my C99-Code. Afterwards I run the tests and check line coverage with gcov. Gcov seems to update coverage data at the end of the run upon successful completion. However, some tests fail (assert statements that are not true), which leads to aborting the program and gcov not counting the lines covered in this run. Is there any way that gcov flushes information on any exit (not only on successful)? 回答1: Call void __gcov

How can I get more accurate results from gcov?

。_饼干妹妹 提交于 2019-11-30 02:43:35
问题 I'm experimenting with gcov using mingw gcc 4.4.0. I've been getting some interesting but strange results. A common pattern is something like this... 5162: 66: std::string::iterator i = l_Temp.begin (); 5162: 67: std::string::iterator j = l_Temp.end () - 1; -: 68: char ch; -: 69: 20564: 70: while (i < j) -: 71: { 10240: 72: ch = *i; *i = *j; *j = ch; i++; j--; -: 73: } -: 74: #####: 75: return l_Temp; -: 76:} How can that return not be exected at all, given that the loop just before clearly

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

风格不统一 提交于 2019-11-30 02:41:21
I'm using gcov to measure coverage in my C++ code. I'd like to get to 100% coverage, but am hampered by the fact that there are some lines of code that are theoretically un-hittable (methods that are required to be implemented but which are never called, default branches of switch statements, etc.). Each of these branches contains an assert( false ); statement, but gcov still marks them as un-hit. I'd like to be able to tell gcov to ignore these branches. Is there any way to give gcov that information -- by annotating the source code, or by any other mechanism? Please use lcov. It hides gcov's

“Hidden symbol `atexit' is referenced by DSO” when using libtool with gcov

蹲街弑〆低调 提交于 2019-11-30 02:15:55
问题 I have a C++ project that uses the GNU Autotools for its build scripts and libtool for linking. Recently I have added code coverage instrumentation with gcov, by ensuring that GCOV_CFLAGS="-fprofile-arcs -ftest-coverage" GCOV_LDFLAGS="-fprofile-arcs -ftest-coverage" ..get included in my CFLAGS and LDFLAGS respectively. On OS X 10.7.4 using g++-4.2 (installed by homebrew), everything works fine. On Ubuntu 12.04 using g++ 4.6.3, libtool fails to link one of my tests: /bin/bash ./libtool --tag

How to resovle __gcov_init undefined reference issue when link

微笑、不失礼 提交于 2019-11-30 01:18:28
I now work on C code coverage study and encountered following issue, GCC version 4.4.6: Added compiler flag CFLAGS = --coverage and linker option LDFLAGS := --coverage or LOCAL_LDLIBS := --coverage and got the error: undefined reference to '__gcov_init'" and "undefined reference to '__gcov_merge_add' Added option LOCAL_LDFLAGS := --coverage , and got link error: libgcov.a(_gcov.o): in function __gcov_set_sampling_rate: undefined reference to '__gcov_sampling_rate' libgcov.a(_gcov.o): in function gcov_exit: undefined reference to '__gcov_pmu_profile_filename' libgcov.a(_gcov.o): in function _

Is there any actively supported lcov port for windows

筅森魡賤 提交于 2019-11-29 21:56:52
问题 I measure coverage for my code using gcov library and I would like to generate coverage report in user-friendly format. I've found lcov utility for that, but it's not compatibile with Windows environment (mainly because of the way the paths are parsed). Does anyone know about actively supported lcov port for Windows? It seems that making it work on Windows would be quite easy (it think it might even be solved by few creative batch/perl scripts that mimic the behavior of unix shell commands),

gcov: producing .gcda output from shared library?

為{幸葍}努か 提交于 2019-11-29 21:25:27
Is it possible to produce gcov data files ( .gcda files) by running an executable linked to a shared library built with the --coverage option? Basically, I have the main library consisting of multiple c++ files compiled into one shared library and then a subdirectory called "test" containing a test program that links to and tests the main library. Everything compiles fine and the .gcno files are produced for both the library source files and the test source files. The .gcda files are only produced for the test source files though, but I really need them for the actual source files that are

GCOVR giving empty results zero percent in MAC

房东的猫 提交于 2019-11-29 18:13:04
I have the .gcda and .gcno files in a folder, from which I am running the below command. $ gcovr -r . and the result is as below if I run gcov on the gcda files I get the proper coverage value. After a tedious search in multiple forums and countless experiments, finally I figured out the issue and resolved it. Two things are important to get the proper output from gcovr. One is from where the gcovr is executed and other is the root directory path. gcovr should be executed from the folder where the .gcda and .gcno files exist. And the root path is the folder where the source files(.c or .cpp)

No code coverage with Mac OS X Lion and XCode 4 / llvm-g++-4.2

别等时光非礼了梦想. 提交于 2019-11-29 14:32:27
Other people have reported not being able to generate code coverage with XCode 4 , but I find not only can I not do it from within XCode 4, I can't do it even with a simple toy program from the command line. I followed the examples given here and here , which led me to create this cov.c file: #include <stdio.h> int main (void) { int i; for (i = 1; i < 10; i++) { if (i % 3 == 0) printf("%d is divisible by 3\n", i); if (i % 11 == 0) printf("%d is divisible by 11\n", i); } return 0; } I then used the following commands in an attempt to generate code coverage: g++ -c -g -O0 --coverage -o $PWD/obj

gcov not generating gcda files

久未见 提交于 2019-11-29 11:12:10
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 referenced by DSO and program exits. Command to compile- bsub -g /mojave/build/"DummyDate" -J compile-obj/linux24rhel3_x86_64_GCOV64/DXp.o -I -q DFM -S 8192 -R "(model==OPTERON_250)" '/usr/bin/time --format=" ...finished DXp [`hostname`] [%E s with %P CPU]" /home/mojave/tools/gcc-4.4.1/amd64/bin/g++ -fPIC -Wall -Wno-deprecated -DTCL_8_5 -m64 -march