【Linux】一步一步学Linux——gcov命令(257)
生活随笔
收集整理的這篇文章主要介紹了
【Linux】一步一步学Linux——gcov命令(257)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
00. 目錄
文章目錄
- 00. 目錄
- 01. 命令概述
- 02. 命令格式
- 03. 常用選項
- 04. 參考示例
- 05. 附錄
01. 命令概述
gcov命令是一款測試程序的代碼覆蓋率的工具。
02. 命令格式
用法:gcov [選項]... SOURCE|OBJ...03. 常用選項
顯示代碼覆蓋信息。-h, --help 打印此幫助并退出-v, --version 打印版本號并退出-a, --all-blocks 顯示每個基本塊的信息-b, --branch-probabilities 輸出包含分支概率-c, --branch-counts 給出跳轉的分支數(shù),而不是百分比-n, --no-output 不創(chuàng)建輸出文件-l, --long-file-names 為包含進來的源文件使用長輸出文件名-f, --function-summaries 輸出每個函數(shù)的小結信息-o, --object-directory DIR|FILE 在 DIR 中搜索目標文件,或搜索名為 FILE 的目標文件-s, --source-prefix DIR Source prefix to elide-r, --relative-only Only show data for relative sources-p, --preserve-paths 保留所有路徑名-u, --unconditional-branches 同時顯示無條件跳轉數(shù)-d, --display-progress 顯示進度信息04. 參考示例
4.1 顯示代碼覆蓋信息
[deng@localhost 1gcc] gcc -fprofile-arcs -ftest-coverage test.c [deng@localhost 1gcc] ls test test.c test.gcno [deng@localhost 1gcc]./test [deng@localhost 1gcc] ls test test.c test.gcda test.gcno [deng@localhost 1gcc] gcov test.c File 'test.c' Lines executed:77.78% of 9 test.c:creating 'test.c.gcov' [deng@localhost 1gcc] cat test.c.gcov-: 0:Source:test.c-: 0:Graph:test.gcno-: 0:Data:test.gcda-: 0:Runs:1-: 0:Programs:1-: 1:#include<stdio.h>-: 2:-: 3:int main(int argc, char *argv[])-: 4:{1: 5: int i = 0;202: 6: for (i = 0; i < 100; i++) {100: 7: printf("add i atomic");100: 8: }-: 9:1: 10: if (i > 200) { #####: 11: printf("i is bigger than 200"); #####: 12: } else {1: 13: printf("is is less then 200");-: 14: }1: 15: return 0;-: 16:}05. 附錄
參考:【Linux】一步一步學Linux系列教程匯總
總結
以上是生活随笔為你收集整理的【Linux】一步一步学Linux——gcov命令(257)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【Linux】一步一步学Linux——l
- 下一篇: 【Linux】一步一步学Linux——g