2013-05-09 51 views
0

我想获得代码覆盖率信息。在运行时只有一个功能。例如,我只想知道哪些行“run()”已经通过。C++代码覆盖期间运行只有一个功能

TEST.CPP:

#include "..." 

int main(){ 
    init(); 
    gcov_start_recording(); 
    run(); 
    gcov_end_recording(); 
    return 0; 
} 
+0

你怎么样谷歌“的gcov”和阅读教程,然后回来,如果你不能得到的指示工作。 – 2013-05-09 12:58:16

回答

1
 
It is unable to get source code information from a normal binary file. 
My basic idea is : 
1. Executable should be complied as debug version , 
which keep the symbol infomation. 
2. You need a external wrapper script for GDB. 

set break point at entry and exit of the function. 
collect trace output from GDB . 
filter the duplicate line in the output . 
finally you will get the code cover information .