GDB -fprofile-arcs -ftest-coverage 選項

-fprofile-arcs -ftest-coverage 選項的使用

參考:https://gcc.gnu.org/onlinedocs/gcc-4.4.1/gcc/Debugging-Options.html

 

-fprofile-arcs

Add code so that program flow arcs are instrumented. During execution the program records how many times each branch and call is executed and how many times it is taken or returns. When the compiled program exits it saves this data to a file called auxname.gcda for each source file. The data may be used for profile-directed optimizations (-fbranch-probabilities), or for test coverage analysis (-ftest-coverage). Each object file's auxname is generated from the name of the output file, if explicitly specified and it is not the final executable, otherwise it is the basename of the source file. In both cases any suffix is removed (e.g. foo.gcda for input file dir/foo.c, or dir/foo.gcda for output file specified as -o dir/foo.o). See Cross-profiling.

添加代碼,以便檢測程序流。在執行期間,程序記錄每個分支和調用執行了多少次,以及執行或返回了多少次。編譯後的程序退出時,對於每個源文件會將數據保存到名爲 auxname.gcda。數據可用於配置文件導向的優化(分支概率),或用於測試覆蓋率分析(-ftest-coverage)。每個目標文件的 auxname由輸出文件的名稱生成(如果已明確指定),它不是最終的可執行文件,否則它是源文件的基本名稱。在這兩種情況下,都刪除了任何後綴(例如,foo.gcda 用於輸入文件 目錄/foo.c, 要麼 目錄/foo.gcda 對於指定爲的輸出文件 -o目錄/foo.o)。請參閱交叉分析

 

-ftest-coverage

Produce a notes file that the gcov code-coverage utility (see gcov—a Test Coverage Program) can use to show program coverage. Each source file's note file is called auxname.gcno. Refer to the -fprofile-arcs option above for a description of auxname and instructions on how to generate test coverage data. Coverage data will match the source files more closely, if you do not optimize.

產生一個註釋文件, gcov 代碼覆蓋實用程序(請參閱 gcov—測試覆蓋率計劃)可用於顯示計劃覆蓋率。每個源文件的註釋文件稱爲 輔助名.gcno。請參閱-fprofile-arcs上面的選項可提供關於auxname的描述以及有關如何生成測試覆蓋率數據的說明。如果不進行優化,覆蓋率數據將與源文件更緊密地匹配。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章