2013-05-09 50 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 .