gcov

Dumping gcov data at runtime

99封情书 提交于 2019-12-08 04:00:35
问题 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 kernel of an operating system which runs in a server that never shuts down - and I need to collect code coverage data for it). Is there any way to make gcov dump code coverage data periodically (say, every 1 hour) or upon certain event - how can I

Exclusion markers for gcov

旧城冷巷雨未停 提交于 2019-12-08 02:06:10
问题 I'm using gcov to measure coverage in my C++ code. I'd like to be able to mark certain lines of source code so that they are excluded from coverage reporting when using gcovr. I know they exist because I stumbled across them once but now I can't find where I saw them. I'm not using lcov to report coverage so references to such markers are no good to me. Can anyone point me to the right place? TIA 回答1: I figured this out finally. The lcov exclusion markers are valid with gcovr. The following

interpret gcov output to identify basic blocks

人盡茶涼 提交于 2019-12-07 23:08:17
问题 I am using gcov with the option -a (--all-blocks) which from the manual: When you use the -a option, you will get individual block counts The original file: #include <stdio.h> #include "file1.h" int max(int a , int b) { int k = 0; if (a > b) return a; else return b; } The gcov file is the following: -: 0:Source:file1.c -: 0:Graph:file1.gcno -: 0:Data:file1.gcda -: 0:Runs:1 -: 0:Programs:1 -: 1:#include <stdio.h> -: 2:#include "file1.h" -: 3: -: 4:int max(int a , int b) 1: 5:{ 1: 6: int k = 0;

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

最后都变了- 提交于 2019-12-07 14:32:27
问题 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? 回答1: Run gcov from the directory where you want its files to be created. You'll have to use the -o argument to tell it where to look for the .gcno/.gcda files. See gcov's docs for more info. 来源: https://stackoverflow.com/questions/1759475/gcov-creates-gcov-files-in-the-current-directory-is-there-any-way-to-change-th

Gcov reporting that return statement is not hit

旧巷老猫 提交于 2019-12-07 09:48:26
gcov complains about one of my algorithms: File 'Algorithm.h' Lines executed:95.00% of 20 Algorithm.h:creating 'Algorithm.h.gcov' 17: 25:inline std::vector<std::string> starts_with(const std::vector<std::string>& input, const std::string& startsWith) -: 26:{ 17: 27: std::vector<std::string> output; 17: 28: std::remove_copy_if(input.begin(), input.end(), std::back_inserter(output), !boost::bind(&boost::starts_with<std::string,std::string>, _1, startsWith)); #####: 29: return output; -: 30:} My test looks like this, and it passes: TEST (TestAlgorithm, starts_with) { std::vector<std::string>

Why does gcov report in-class function definitions as not executable?

折月煮酒 提交于 2019-12-06 13:48:46
问题 It seems like gcov does not report inline definitions of class methods as executable lines. Example: #include <iostream> struct Foo { void bar() {} void baz() {} }; int main() { Foo foo; foo.bar(); } If I compile the above program with g++ -g -O0 -ftest-coverage -fprofile-arcs -o main main.cpp , run it, and call gcov on it, I get the following report: -: 0:Source:main.cpp -: 0:Graph:main.gcno -: 0:Data:main.gcda -: 0:Runs:1 -: 0:Programs:1 -: 1:#include <iostream> -: 2: -: 3:struct Foo { 1: 4

Code coverage with GCOV can't produce .gcda file

依然范特西╮ 提交于 2019-12-06 09:33:45
I want to get code coverage with GCOV, I set build setting by http://developer.apple.com/library/mac/#qa/qa2007/qa1514.html add "-lgcov" to "Other Linker Flags" check "Instrument Program Flow" check "Generate Test Coverage Files" but I can't produce the .gcda file, could anyone help? The simulator has to close before the gcda files get generated. So, when I run GHUnit I have to close this app first. There's also a setting in the plist to kill the app when it closes, rather than have it sit there ready to restart. Sangavi I have posted the settings and configurations that worked for me at Code

How to find the coverage of a library opened using dlopen()?

江枫思渺然 提交于 2019-12-06 08:08:47
I have a C++ library (.so) which is opened using dlopen() by another application. But I need to find the code coverage of this library while run within the application using gcov. Is it possible? If yes, how can it be done? If not, how can the issue be resolved? Firstly have your compiled your C++ library with the --coverage flag? I've never actually used a '.so' library with gcov before, so I'm not sure it would work anyway. Secondly could you arrange a test version of your application to not use dlopen() , but instead be linked to a static library(.a) version of your library and still make

Exclusion markers for gcov

岁酱吖の 提交于 2019-12-06 07:47:29
I'm using gcov to measure coverage in my C++ code. I'd like to be able to mark certain lines of source code so that they are excluded from coverage reporting when using gcovr. I know they exist because I stumbled across them once but now I can't find where I saw them. I'm not using lcov to report coverage so references to such markers are no good to me. Can anyone point me to the right place? TIA I figured this out finally. The lcov exclusion markers are valid with gcovr. The following markers are recognized by geninfo: LCOV_EXCL_LINE Lines containing this marker will be excluded. LCOV_EXCL

No source code coverage color highlighting in eclipse-cpp-luna-SR1 for static library project

二次信任 提交于 2019-12-06 07:03:12
问题 I'm using eclipse-cpp-luna-SR1 for both Linux and Windows with tool chain gcc 4.9.1 Code is partitioned into two projects: Production code in a static library project Properties|C/C++ Build|Settings|Debugging|Generate gcov information (-ftest-coverage -fprofile-arcs) is enabled Client/Test code in an executable project Also Generate gcov information is enabled Running the program from the executable project with Profiling Tools|Profile Code Coverage works fine, and the result is presented in