riscv-none-embed-gcov.1 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945
  1. .\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35)
  2. .\"
  3. .\" Standard preamble:
  4. .\" ========================================================================
  5. .de Sp \" Vertical space (when we can't use .PP)
  6. .if t .sp .5v
  7. .if n .sp
  8. ..
  9. .de Vb \" Begin verbatim text
  10. .ft CW
  11. .nf
  12. .ne \\$1
  13. ..
  14. .de Ve \" End verbatim text
  15. .ft R
  16. .fi
  17. ..
  18. .\" Set up some character translations and predefined strings. \*(-- will
  19. .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
  20. .\" double quote, and \*(R" will give a right double quote. \*(C+ will
  21. .\" give a nicer C++. Capital omega is used to do unbreakable dashes and
  22. .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
  23. .\" nothing in troff, for use with C<>.
  24. .tr \(*W-
  25. .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
  26. .ie n \{\
  27. . ds -- \(*W-
  28. . ds PI pi
  29. . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
  30. . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
  31. . ds L" ""
  32. . ds R" ""
  33. . ds C` ""
  34. . ds C' ""
  35. 'br\}
  36. .el\{\
  37. . ds -- \|\(em\|
  38. . ds PI \(*p
  39. . ds L" ``
  40. . ds R" ''
  41. . ds C`
  42. . ds C'
  43. 'br\}
  44. .\"
  45. .\" Escape single quotes in literal strings from groff's Unicode transform.
  46. .ie \n(.g .ds Aq \(aq
  47. .el .ds Aq '
  48. .\"
  49. .\" If the F register is >0, we'll generate index entries on stderr for
  50. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  51. .\" entries marked with X<> in POD. Of course, you'll have to process the
  52. .\" output yourself in some meaningful fashion.
  53. .\"
  54. .\" Avoid warning from groff about undefined register 'F'.
  55. .de IX
  56. ..
  57. .nr rF 0
  58. .if \n(.g .if rF .nr rF 1
  59. .if (\n(rF:(\n(.g==0)) \{\
  60. . if \nF \{\
  61. . de IX
  62. . tm Index:\\$1\t\\n%\t"\\$2"
  63. ..
  64. . if !\nF==2 \{\
  65. . nr % 0
  66. . nr F 2
  67. . \}
  68. . \}
  69. .\}
  70. .rr rF
  71. .\"
  72. .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
  73. .\" Fear. Run. Save yourself. No user-serviceable parts.
  74. . \" fudge factors for nroff and troff
  75. .if n \{\
  76. . ds #H 0
  77. . ds #V .8m
  78. . ds #F .3m
  79. . ds #[ \f1
  80. . ds #] \fP
  81. .\}
  82. .if t \{\
  83. . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
  84. . ds #V .6m
  85. . ds #F 0
  86. . ds #[ \&
  87. . ds #] \&
  88. .\}
  89. . \" simple accents for nroff and troff
  90. .if n \{\
  91. . ds ' \&
  92. . ds ` \&
  93. . ds ^ \&
  94. . ds , \&
  95. . ds ~ ~
  96. . ds /
  97. .\}
  98. .if t \{\
  99. . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
  100. . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
  101. . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
  102. . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
  103. . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
  104. . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
  105. .\}
  106. . \" troff and (daisy-wheel) nroff accents
  107. .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
  108. .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
  109. .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
  110. .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
  111. .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
  112. .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
  113. .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
  114. .ds ae a\h'-(\w'a'u*4/10)'e
  115. .ds Ae A\h'-(\w'A'u*4/10)'E
  116. . \" corrections for vroff
  117. .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
  118. .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
  119. . \" for low resolution devices (crt and lpr)
  120. .if \n(.H>23 .if \n(.V>19 \
  121. \{\
  122. . ds : e
  123. . ds 8 ss
  124. . ds o a
  125. . ds d- d\h'-1'\(ga
  126. . ds D- D\h'-1'\(hy
  127. . ds th \o'bp'
  128. . ds Th \o'LP'
  129. . ds ae ae
  130. . ds Ae AE
  131. .\}
  132. .rm #[ #] #H #V #F C
  133. .\" ========================================================================
  134. .\"
  135. .IX Title "GCOV 1"
  136. .TH GCOV 1 "2019-02-22" "gcc-8.3.0" "GNU"
  137. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  138. .\" way too many mistakes in technical documents.
  139. .if n .ad l
  140. .nh
  141. .SH "NAME"
  142. gcov \- coverage testing tool
  143. .SH "SYNOPSIS"
  144. .IX Header "SYNOPSIS"
  145. gcov [\fB\-v\fR|\fB\-\-version\fR] [\fB\-h\fR|\fB\-\-help\fR]
  146. [\fB\-a\fR|\fB\-\-all\-blocks\fR]
  147. [\fB\-b\fR|\fB\-\-branch\-probabilities\fR]
  148. [\fB\-c\fR|\fB\-\-branch\-counts\fR]
  149. [\fB\-d\fR|\fB\-\-display\-progress\fR]
  150. [\fB\-f\fR|\fB\-\-function\-summaries\fR]
  151. [\fB\-i\fR|\fB\-\-intermediate\-format\fR]
  152. [\fB\-j\fR|\fB\-\-human\-readable\fR]
  153. [\fB\-k\fR|\fB\-\-use\-colors\fR]
  154. [\fB\-l\fR|\fB\-\-long\-file\-names\fR]
  155. [\fB\-m\fR|\fB\-\-demangled\-names\fR]
  156. [\fB\-n\fR|\fB\-\-no\-output\fR]
  157. [\fB\-o\fR|\fB\-\-object\-directory\fR \fIdirectory|file\fR]
  158. [\fB\-p\fR|\fB\-\-preserve\-paths\fR]
  159. [\fB\-r\fR|\fB\-\-relative\-only\fR]
  160. [\fB\-s\fR|\fB\-\-source\-prefix\fR \fIdirectory\fR]
  161. [\fB\-u\fR|\fB\-\-unconditional\-branches\fR]
  162. [\fB\-x\fR|\fB\-\-hash\-filenames\fR]
  163. \fIfiles\fR
  164. .SH "DESCRIPTION"
  165. .IX Header "DESCRIPTION"
  166. \&\fBgcov\fR is a test coverage program. Use it in concert with \s-1GCC\s0
  167. to analyze your programs to help create more efficient, faster running
  168. code and to discover untested parts of your program. You can use
  169. \&\fBgcov\fR as a profiling tool to help discover where your
  170. optimization efforts will best affect your code. You can also use
  171. \&\fBgcov\fR along with the other profiling tool, \fBgprof\fR, to
  172. assess which parts of your code use the greatest amount of computing
  173. time.
  174. .PP
  175. Profiling tools help you analyze your code's performance. Using a
  176. profiler such as \fBgcov\fR or \fBgprof\fR, you can find out some
  177. basic performance statistics, such as:
  178. .IP "*" 4
  179. how often each line of code executes
  180. .IP "*" 4
  181. what lines of code are actually executed
  182. .IP "*" 4
  183. how much computing time each section of code uses
  184. .PP
  185. Once you know these things about how your code works when compiled, you
  186. can look at each module to see which modules should be optimized.
  187. \&\fBgcov\fR helps you determine where to work on optimization.
  188. .PP
  189. Software developers also use coverage testing in concert with
  190. testsuites, to make sure software is actually good enough for a release.
  191. Testsuites can verify that a program works as expected; a coverage
  192. program tests to see how much of the program is exercised by the
  193. testsuite. Developers can then determine what kinds of test cases need
  194. to be added to the testsuites to create both better testing and a better
  195. final product.
  196. .PP
  197. You should compile your code without optimization if you plan to use
  198. \&\fBgcov\fR because the optimization, by combining some lines of code
  199. into one function, may not give you as much information as you need to
  200. look for `hot spots' where the code is using a great deal of computer
  201. time. Likewise, because \fBgcov\fR accumulates statistics by line (at
  202. the lowest resolution), it works best with a programming style that
  203. places only one statement on each line. If you use complicated macros
  204. that expand to loops or to other control structures, the statistics are
  205. less helpful\-\-\-they only report on the line where the macro call
  206. appears. If your complex macros behave like functions, you can replace
  207. them with inline functions to solve this problem.
  208. .PP
  209. \&\fBgcov\fR creates a logfile called \fI\fIsourcefile\fI.gcov\fR which
  210. indicates how many times each line of a source file \fI\fIsourcefile\fI.c\fR
  211. has executed. You can use these logfiles along with \fBgprof\fR to aid
  212. in fine-tuning the performance of your programs. \fBgprof\fR gives
  213. timing information you can use along with the information you get from
  214. \&\fBgcov\fR.
  215. .PP
  216. \&\fBgcov\fR works only on code compiled with \s-1GCC.\s0 It is not
  217. compatible with any other profiling or test coverage mechanism.
  218. .SH "OPTIONS"
  219. .IX Header "OPTIONS"
  220. .IP "\fB\-a\fR" 4
  221. .IX Item "-a"
  222. .PD 0
  223. .IP "\fB\-\-all\-blocks\fR" 4
  224. .IX Item "--all-blocks"
  225. .PD
  226. Write individual execution counts for every basic block. Normally gcov
  227. outputs execution counts only for the main blocks of a line. With this
  228. option you can determine if blocks within a single line are not being
  229. executed.
  230. .IP "\fB\-b\fR" 4
  231. .IX Item "-b"
  232. .PD 0
  233. .IP "\fB\-\-branch\-probabilities\fR" 4
  234. .IX Item "--branch-probabilities"
  235. .PD
  236. Write branch frequencies to the output file, and write branch summary
  237. info to the standard output. This option allows you to see how often
  238. each branch in your program was taken. Unconditional branches will not
  239. be shown, unless the \fB\-u\fR option is given.
  240. .IP "\fB\-c\fR" 4
  241. .IX Item "-c"
  242. .PD 0
  243. .IP "\fB\-\-branch\-counts\fR" 4
  244. .IX Item "--branch-counts"
  245. .PD
  246. Write branch frequencies as the number of branches taken, rather than
  247. the percentage of branches taken.
  248. .IP "\fB\-d\fR" 4
  249. .IX Item "-d"
  250. .PD 0
  251. .IP "\fB\-\-display\-progress\fR" 4
  252. .IX Item "--display-progress"
  253. .PD
  254. Display the progress on the standard output.
  255. .IP "\fB\-f\fR" 4
  256. .IX Item "-f"
  257. .PD 0
  258. .IP "\fB\-\-function\-summaries\fR" 4
  259. .IX Item "--function-summaries"
  260. .PD
  261. Output summaries for each function in addition to the file level summary.
  262. .IP "\fB\-h\fR" 4
  263. .IX Item "-h"
  264. .PD 0
  265. .IP "\fB\-\-help\fR" 4
  266. .IX Item "--help"
  267. .PD
  268. Display help about using \fBgcov\fR (on the standard output), and
  269. exit without doing any further processing.
  270. .IP "\fB\-i\fR" 4
  271. .IX Item "-i"
  272. .PD 0
  273. .IP "\fB\-\-intermediate\-format\fR" 4
  274. .IX Item "--intermediate-format"
  275. .PD
  276. Output gcov file in an easy-to-parse intermediate text format that can
  277. be used by \fBlcov\fR or other tools. The output is a single
  278. \&\fI.gcov\fR file per \fI.gcda\fR file. No source code is required.
  279. .Sp
  280. The format of the intermediate \fI.gcov\fR file is plain text with
  281. one entry per line
  282. .Sp
  283. .Vb 5
  284. \& version:<gcc_version>
  285. \& file:<source_file_name>
  286. \& function:<start_line_number>,<end_line_number>,<execution_count>,<function_name>
  287. \& lcount:<line number>,<execution_count>,<has_unexecuted_block>
  288. \& branch:<line_number>,<branch_coverage_type>
  289. \&
  290. \& Where the <branch_coverage_type> is
  291. \& notexec (Branch not executed)
  292. \& taken (Branch executed and taken)
  293. \& nottaken (Branch executed, but not taken)
  294. .Ve
  295. .Sp
  296. There can be multiple \fIfile\fR entries in an intermediate gcov
  297. file. All entries following a \fIfile\fR pertain to that source file
  298. until the next \fIfile\fR entry. If there are multiple functions that
  299. start on a single line, then corresponding lcount is repeated multiple
  300. times.
  301. .Sp
  302. Here is a sample when \fB\-i\fR is used in conjunction with \fB\-b\fR option:
  303. .Sp
  304. .Vb 10
  305. \& version: 8.1.0 20180103
  306. \& file:tmp.cpp
  307. \& function:7,7,0,_ZN3FooIcEC2Ev
  308. \& function:7,7,1,_ZN3FooIiEC2Ev
  309. \& function:8,8,0,_ZN3FooIcE3incEv
  310. \& function:8,8,2,_ZN3FooIiE3incEv
  311. \& function:18,37,1,main
  312. \& lcount:7,0,1
  313. \& lcount:7,1,0
  314. \& lcount:8,0,1
  315. \& lcount:8,2,0
  316. \& lcount:18,1,0
  317. \& lcount:21,1,0
  318. \& branch:21,taken
  319. \& branch:21,nottaken
  320. \& lcount:23,1,0
  321. \& branch:23,taken
  322. \& branch:23,nottaken
  323. \& lcount:24,1,0
  324. \& branch:24,taken
  325. \& branch:24,nottaken
  326. \& lcount:25,1,0
  327. \& lcount:27,11,0
  328. \& branch:27,taken
  329. \& branch:27,taken
  330. \& lcount:28,10,0
  331. \& lcount:30,1,1
  332. \& branch:30,nottaken
  333. \& branch:30,taken
  334. \& lcount:32,1,0
  335. \& branch:32,nottaken
  336. \& branch:32,taken
  337. \& lcount:33,0,1
  338. \& branch:33,notexec
  339. \& branch:33,notexec
  340. \& lcount:35,1,0
  341. \& branch:35,taken
  342. \& branch:35,nottaken
  343. \& lcount:36,1,0
  344. .Ve
  345. .IP "\fB\-j\fR" 4
  346. .IX Item "-j"
  347. .PD 0
  348. .IP "\fB\-\-human\-readable\fR" 4
  349. .IX Item "--human-readable"
  350. .PD
  351. Write counts in human readable format (like 24k).
  352. .IP "\fB\-k\fR" 4
  353. .IX Item "-k"
  354. .PD 0
  355. .IP "\fB\-\-use\-colors\fR" 4
  356. .IX Item "--use-colors"
  357. .PD
  358. Use colors for lines of code that have zero coverage. We use red color for
  359. non-exceptional lines and cyan for exceptional. Same colors are used for
  360. basic blocks with \fB\-a\fR option.
  361. .IP "\fB\-l\fR" 4
  362. .IX Item "-l"
  363. .PD 0
  364. .IP "\fB\-\-long\-file\-names\fR" 4
  365. .IX Item "--long-file-names"
  366. .PD
  367. Create long file names for included source files. For example, if the
  368. header file \fIx.h\fR contains code, and was included in the file
  369. \&\fIa.c\fR, then running \fBgcov\fR on the file \fIa.c\fR will
  370. produce an output file called \fIa.c##x.h.gcov\fR instead of
  371. \&\fIx.h.gcov\fR. This can be useful if \fIx.h\fR is included in
  372. multiple source files and you want to see the individual
  373. contributions. If you use the \fB\-p\fR option, both the including
  374. and included file names will be complete path names.
  375. .IP "\fB\-m\fR" 4
  376. .IX Item "-m"
  377. .PD 0
  378. .IP "\fB\-\-demangled\-names\fR" 4
  379. .IX Item "--demangled-names"
  380. .PD
  381. Display demangled function names in output. The default is to show
  382. mangled function names.
  383. .IP "\fB\-n\fR" 4
  384. .IX Item "-n"
  385. .PD 0
  386. .IP "\fB\-\-no\-output\fR" 4
  387. .IX Item "--no-output"
  388. .PD
  389. Do not create the \fBgcov\fR output file.
  390. .IP "\fB\-o\fR \fIdirectory|file\fR" 4
  391. .IX Item "-o directory|file"
  392. .PD 0
  393. .IP "\fB\-\-object\-directory\fR \fIdirectory\fR" 4
  394. .IX Item "--object-directory directory"
  395. .IP "\fB\-\-object\-file\fR \fIfile\fR" 4
  396. .IX Item "--object-file file"
  397. .PD
  398. Specify either the directory containing the gcov data files, or the
  399. object path name. The \fI.gcno\fR, and
  400. \&\fI.gcda\fR data files are searched for using this option. If a directory
  401. is specified, the data files are in that directory and named after the
  402. input file name, without its extension. If a file is specified here,
  403. the data files are named after that file, without its extension.
  404. .IP "\fB\-p\fR" 4
  405. .IX Item "-p"
  406. .PD 0
  407. .IP "\fB\-\-preserve\-paths\fR" 4
  408. .IX Item "--preserve-paths"
  409. .PD
  410. Preserve complete path information in the names of generated
  411. \&\fI.gcov\fR files. Without this option, just the filename component is
  412. used. With this option, all directories are used, with \fB/\fR characters
  413. translated to \fB#\fR characters, \fI.\fR directory components
  414. removed and unremoveable \fI..\fR
  415. components renamed to \fB^\fR. This is useful if sourcefiles are in several
  416. different directories.
  417. .IP "\fB\-r\fR" 4
  418. .IX Item "-r"
  419. .PD 0
  420. .IP "\fB\-\-relative\-only\fR" 4
  421. .IX Item "--relative-only"
  422. .PD
  423. Only output information about source files with a relative pathname
  424. (after source prefix elision). Absolute paths are usually system
  425. header files and coverage of any inline functions therein is normally
  426. uninteresting.
  427. .IP "\fB\-s\fR \fIdirectory\fR" 4
  428. .IX Item "-s directory"
  429. .PD 0
  430. .IP "\fB\-\-source\-prefix\fR \fIdirectory\fR" 4
  431. .IX Item "--source-prefix directory"
  432. .PD
  433. A prefix for source file names to remove when generating the output
  434. coverage files. This option is useful when building in a separate
  435. directory, and the pathname to the source directory is not wanted when
  436. determining the output file names. Note that this prefix detection is
  437. applied before determining whether the source file is absolute.
  438. .IP "\fB\-u\fR" 4
  439. .IX Item "-u"
  440. .PD 0
  441. .IP "\fB\-\-unconditional\-branches\fR" 4
  442. .IX Item "--unconditional-branches"
  443. .PD
  444. When branch probabilities are given, include those of unconditional branches.
  445. Unconditional branches are normally not interesting.
  446. .IP "\fB\-v\fR" 4
  447. .IX Item "-v"
  448. .PD 0
  449. .IP "\fB\-\-version\fR" 4
  450. .IX Item "--version"
  451. .PD
  452. Display the \fBgcov\fR version number (on the standard output),
  453. and exit without doing any further processing.
  454. .IP "\fB\-w\fR" 4
  455. .IX Item "-w"
  456. .PD 0
  457. .IP "\fB\-\-verbose\fR" 4
  458. .IX Item "--verbose"
  459. .PD
  460. Print verbose informations related to basic blocks and arcs.
  461. .IP "\fB\-x\fR" 4
  462. .IX Item "-x"
  463. .PD 0
  464. .IP "\fB\-\-hash\-filenames\fR" 4
  465. .IX Item "--hash-filenames"
  466. .PD
  467. By default, gcov uses the full pathname of the source files to create
  468. an output filename. This can lead to long filenames that can overflow
  469. filesystem limits. This option creates names of the form
  470. \&\fI\fIsource-file\fI##\fImd5\fI.gcov\fR,
  471. where the \fIsource-file\fR component is the final filename part and
  472. the \fImd5\fR component is calculated from the full mangled name that
  473. would have been used otherwise.
  474. .PP
  475. \&\fBgcov\fR should be run with the current directory the same as that
  476. when you invoked the compiler. Otherwise it will not be able to locate
  477. the source files. \fBgcov\fR produces files called
  478. \&\fI\fImangledname\fI.gcov\fR in the current directory. These contain
  479. the coverage information of the source file they correspond to.
  480. One \fI.gcov\fR file is produced for each source (or header) file
  481. containing code,
  482. which was compiled to produce the data files. The \fImangledname\fR part
  483. of the output file name is usually simply the source file name, but can
  484. be something more complicated if the \fB\-l\fR or \fB\-p\fR options are
  485. given. Refer to those options for details.
  486. .PP
  487. If you invoke \fBgcov\fR with multiple input files, the
  488. contributions from each input file are summed. Typically you would
  489. invoke it with the same list of files as the final link of your executable.
  490. .PP
  491. The \fI.gcov\fR files contain the \fB:\fR separated fields along with
  492. program source code. The format is
  493. .PP
  494. .Vb 1
  495. \& <execution_count>:<line_number>:<source line text>
  496. .Ve
  497. .PP
  498. Additional block information may succeed each line, when requested by
  499. command line option. The \fIexecution_count\fR is \fB\-\fR for lines
  500. containing no code. Unexecuted lines are marked \fB#####\fR or
  501. \&\fB=====\fR, depending on whether they are reachable by
  502. non-exceptional paths or only exceptional paths such as \*(C+ exception
  503. handlers, respectively. Given \fB\-a\fR option, unexecuted blocks are
  504. marked \fB$$$$$\fR or \fB%%%%%\fR, depending on whether a basic block
  505. is reachable via non-exceptional or exceptional paths.
  506. Executed basic blocks having a statement with zero \fIexecution_count\fR
  507. end with \fB*\fR character and are colored with magenta color with \fB\-k\fR
  508. option. The functionality is not supported in Ada.
  509. .PP
  510. Note that \s-1GCC\s0 can completely remove the bodies of functions that are
  511. not needed \*(-- for instance if they are inlined everywhere. Such functions
  512. are marked with \fB\-\fR, which can be confusing.
  513. Use the \fB\-fkeep\-inline\-functions\fR and \fB\-fkeep\-static\-functions\fR
  514. options to retain these functions and
  515. allow gcov to properly show their \fIexecution_count\fR.
  516. .PP
  517. Some lines of information at the start have \fIline_number\fR of zero.
  518. These preamble lines are of the form
  519. .PP
  520. .Vb 1
  521. \& \-:0:<tag>:<value>
  522. .Ve
  523. .PP
  524. The ordering and number of these preamble lines will be augmented as
  525. \&\fBgcov\fR development progresses \-\-\- do not rely on them remaining
  526. unchanged. Use \fItag\fR to locate a particular preamble line.
  527. .PP
  528. The additional block information is of the form
  529. .PP
  530. .Vb 1
  531. \& <tag> <information>
  532. .Ve
  533. .PP
  534. The \fIinformation\fR is human readable, but designed to be simple
  535. enough for machine parsing too.
  536. .PP
  537. When printing percentages, 0% and 100% are only printed when the values
  538. are \fIexactly\fR 0% and 100% respectively. Other values which would
  539. conventionally be rounded to 0% or 100% are instead printed as the
  540. nearest non-boundary value.
  541. .PP
  542. When using \fBgcov\fR, you must first compile your program with two
  543. special \s-1GCC\s0 options: \fB\-fprofile\-arcs \-ftest\-coverage\fR.
  544. This tells the compiler to generate additional information needed by
  545. gcov (basically a flow graph of the program) and also includes
  546. additional code in the object files for generating the extra profiling
  547. information needed by gcov. These additional files are placed in the
  548. directory where the object file is located.
  549. .PP
  550. Running the program will cause profile output to be generated. For each
  551. source file compiled with \fB\-fprofile\-arcs\fR, an accompanying
  552. \&\fI.gcda\fR file will be placed in the object file directory.
  553. .PP
  554. Running \fBgcov\fR with your program's source file names as arguments
  555. will now produce a listing of the code along with frequency of execution
  556. for each line. For example, if your program is called \fItmp.cpp\fR, this
  557. is what you see when you use the basic \fBgcov\fR facility:
  558. .PP
  559. .Vb 6
  560. \& $ g++ \-fprofile\-arcs \-ftest\-coverage tmp.cpp
  561. \& $ a.out
  562. \& $ gcov tmp.cpp \-m
  563. \& File \*(Aqtmp.cpp\*(Aq
  564. \& Lines executed:92.86% of 14
  565. \& Creating \*(Aqtmp.cpp.gcov\*(Aq
  566. .Ve
  567. .PP
  568. The file \fItmp.cpp.gcov\fR contains output from \fBgcov\fR.
  569. Here is a sample:
  570. .PP
  571. .Vb 10
  572. \& \-: 0:Source:tmp.cpp
  573. \& \-: 0:Graph:tmp.gcno
  574. \& \-: 0:Data:tmp.gcda
  575. \& \-: 0:Runs:1
  576. \& \-: 0:Programs:1
  577. \& \-: 1:#include <stdio.h>
  578. \& \-: 2:
  579. \& \-: 3:template<class T>
  580. \& \-: 4:class Foo
  581. \& \-: 5:{
  582. \& \-: 6: public:
  583. \& 1*: 7: Foo(): b (1000) {}
  584. \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
  585. \& Foo<char>::Foo():
  586. \& #####: 7: Foo(): b (1000) {}
  587. \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
  588. \& Foo<int>::Foo():
  589. \& 1: 7: Foo(): b (1000) {}
  590. \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
  591. \& 2*: 8: void inc () { b++; }
  592. \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
  593. \& Foo<char>::inc():
  594. \& #####: 8: void inc () { b++; }
  595. \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
  596. \& Foo<int>::inc():
  597. \& 2: 8: void inc () { b++; }
  598. \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
  599. \& \-: 9:
  600. \& \-: 10: private:
  601. \& \-: 11: int b;
  602. \& \-: 12:};
  603. \& \-: 13:
  604. \& \-: 14:template class Foo<int>;
  605. \& \-: 15:template class Foo<char>;
  606. \& \-: 16:
  607. \& \-: 17:int
  608. \& 1: 18:main (void)
  609. \& \-: 19:{
  610. \& \-: 20: int i, total;
  611. \& 1: 21: Foo<int> counter;
  612. \& \-: 22:
  613. \& 1: 23: counter.inc();
  614. \& 1: 24: counter.inc();
  615. \& 1: 25: total = 0;
  616. \& \-: 26:
  617. \& 11: 27: for (i = 0; i < 10; i++)
  618. \& 10: 28: total += i;
  619. \& \-: 29:
  620. \& 1*: 30: int v = total > 100 ? 1 : 2;
  621. \& \-: 31:
  622. \& 1: 32: if (total != 45)
  623. \& #####: 33: printf ("Failure\en");
  624. \& \-: 34: else
  625. \& 1: 35: printf ("Success\en");
  626. \& 1: 36: return 0;
  627. \& \-: 37:}
  628. .Ve
  629. .PP
  630. Note that line 7 is shown in the report multiple times. First occurrence
  631. presents total number of execution of the line and the next two belong
  632. to instances of class Foo constructors. As you can also see, line 30 contains
  633. some unexecuted basic blocks and thus execution count has asterisk symbol.
  634. .PP
  635. When you use the \fB\-a\fR option, you will get individual block
  636. counts, and the output looks like this:
  637. .PP
  638. .Vb 10
  639. \& \-: 0:Source:tmp.cpp
  640. \& \-: 0:Graph:tmp.gcno
  641. \& \-: 0:Data:tmp.gcda
  642. \& \-: 0:Runs:1
  643. \& \-: 0:Programs:1
  644. \& \-: 1:#include <stdio.h>
  645. \& \-: 2:
  646. \& \-: 3:template<class T>
  647. \& \-: 4:class Foo
  648. \& \-: 5:{
  649. \& \-: 6: public:
  650. \& 1*: 7: Foo(): b (1000) {}
  651. \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
  652. \& Foo<char>::Foo():
  653. \& #####: 7: Foo(): b (1000) {}
  654. \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
  655. \& Foo<int>::Foo():
  656. \& 1: 7: Foo(): b (1000) {}
  657. \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
  658. \& 2*: 8: void inc () { b++; }
  659. \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
  660. \& Foo<char>::inc():
  661. \& #####: 8: void inc () { b++; }
  662. \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
  663. \& Foo<int>::inc():
  664. \& 2: 8: void inc () { b++; }
  665. \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
  666. \& \-: 9:
  667. \& \-: 10: private:
  668. \& \-: 11: int b;
  669. \& \-: 12:};
  670. \& \-: 13:
  671. \& \-: 14:template class Foo<int>;
  672. \& \-: 15:template class Foo<char>;
  673. \& \-: 16:
  674. \& \-: 17:int
  675. \& 1: 18:main (void)
  676. \& \-: 19:{
  677. \& \-: 20: int i, total;
  678. \& 1: 21: Foo<int> counter;
  679. \& 1: 21\-block 0
  680. \& \-: 22:
  681. \& 1: 23: counter.inc();
  682. \& 1: 23\-block 0
  683. \& 1: 24: counter.inc();
  684. \& 1: 24\-block 0
  685. \& 1: 25: total = 0;
  686. \& \-: 26:
  687. \& 11: 27: for (i = 0; i < 10; i++)
  688. \& 1: 27\-block 0
  689. \& 11: 27\-block 1
  690. \& 10: 28: total += i;
  691. \& 10: 28\-block 0
  692. \& \-: 29:
  693. \& 1*: 30: int v = total > 100 ? 1 : 2;
  694. \& 1: 30\-block 0
  695. \& %%%%%: 30\-block 1
  696. \& 1: 30\-block 2
  697. \& \-: 31:
  698. \& 1: 32: if (total != 45)
  699. \& 1: 32\-block 0
  700. \& #####: 33: printf ("Failure\en");
  701. \& %%%%%: 33\-block 0
  702. \& \-: 34: else
  703. \& 1: 35: printf ("Success\en");
  704. \& 1: 35\-block 0
  705. \& 1: 36: return 0;
  706. \& 1: 36\-block 0
  707. \& \-: 37:}
  708. .Ve
  709. .PP
  710. In this mode, each basic block is only shown on one line \*(-- the last
  711. line of the block. A multi-line block will only contribute to the
  712. execution count of that last line, and other lines will not be shown
  713. to contain code, unless previous blocks end on those lines.
  714. The total execution count of a line is shown and subsequent lines show
  715. the execution counts for individual blocks that end on that line. After each
  716. block, the branch and call counts of the block will be shown, if the
  717. \&\fB\-b\fR option is given.
  718. .PP
  719. Because of the way \s-1GCC\s0 instruments calls, a call count can be shown
  720. after a line with no individual blocks.
  721. As you can see, line 33 contains a basic block that was not executed.
  722. .PP
  723. When you use the \fB\-b\fR option, your output looks like this:
  724. .PP
  725. .Vb 10
  726. \& \-: 0:Source:tmp.cpp
  727. \& \-: 0:Graph:tmp.gcno
  728. \& \-: 0:Data:tmp.gcda
  729. \& \-: 0:Runs:1
  730. \& \-: 0:Programs:1
  731. \& \-: 1:#include <stdio.h>
  732. \& \-: 2:
  733. \& \-: 3:template<class T>
  734. \& \-: 4:class Foo
  735. \& \-: 5:{
  736. \& \-: 6: public:
  737. \& 1*: 7: Foo(): b (1000) {}
  738. \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
  739. \& Foo<char>::Foo():
  740. \& function Foo<char>::Foo() called 0 returned 0% blocks executed 0%
  741. \& #####: 7: Foo(): b (1000) {}
  742. \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
  743. \& Foo<int>::Foo():
  744. \& function Foo<int>::Foo() called 1 returned 100% blocks executed 100%
  745. \& 1: 7: Foo(): b (1000) {}
  746. \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
  747. \& 2*: 8: void inc () { b++; }
  748. \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
  749. \& Foo<char>::inc():
  750. \& function Foo<char>::inc() called 0 returned 0% blocks executed 0%
  751. \& #####: 8: void inc () { b++; }
  752. \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
  753. \& Foo<int>::inc():
  754. \& function Foo<int>::inc() called 2 returned 100% blocks executed 100%
  755. \& 2: 8: void inc () { b++; }
  756. \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
  757. \& \-: 9:
  758. \& \-: 10: private:
  759. \& \-: 11: int b;
  760. \& \-: 12:};
  761. \& \-: 13:
  762. \& \-: 14:template class Foo<int>;
  763. \& \-: 15:template class Foo<char>;
  764. \& \-: 16:
  765. \& \-: 17:int
  766. \& function main called 1 returned 100% blocks executed 81%
  767. \& 1: 18:main (void)
  768. \& \-: 19:{
  769. \& \-: 20: int i, total;
  770. \& 1: 21: Foo<int> counter;
  771. \& call 0 returned 100%
  772. \& branch 1 taken 100% (fallthrough)
  773. \& branch 2 taken 0% (throw)
  774. \& \-: 22:
  775. \& 1: 23: counter.inc();
  776. \& call 0 returned 100%
  777. \& branch 1 taken 100% (fallthrough)
  778. \& branch 2 taken 0% (throw)
  779. \& 1: 24: counter.inc();
  780. \& call 0 returned 100%
  781. \& branch 1 taken 100% (fallthrough)
  782. \& branch 2 taken 0% (throw)
  783. \& 1: 25: total = 0;
  784. \& \-: 26:
  785. \& 11: 27: for (i = 0; i < 10; i++)
  786. \& branch 0 taken 91% (fallthrough)
  787. \& branch 1 taken 9%
  788. \& 10: 28: total += i;
  789. \& \-: 29:
  790. \& 1*: 30: int v = total > 100 ? 1 : 2;
  791. \& branch 0 taken 0% (fallthrough)
  792. \& branch 1 taken 100%
  793. \& \-: 31:
  794. \& 1: 32: if (total != 45)
  795. \& branch 0 taken 0% (fallthrough)
  796. \& branch 1 taken 100%
  797. \& #####: 33: printf ("Failure\en");
  798. \& call 0 never executed
  799. \& branch 1 never executed
  800. \& branch 2 never executed
  801. \& \-: 34: else
  802. \& 1: 35: printf ("Success\en");
  803. \& call 0 returned 100%
  804. \& branch 1 taken 100% (fallthrough)
  805. \& branch 2 taken 0% (throw)
  806. \& 1: 36: return 0;
  807. \& \-: 37:}
  808. .Ve
  809. .PP
  810. For each function, a line is printed showing how many times the function
  811. is called, how many times it returns and what percentage of the
  812. function's blocks were executed.
  813. .PP
  814. For each basic block, a line is printed after the last line of the basic
  815. block describing the branch or call that ends the basic block. There can
  816. be multiple branches and calls listed for a single source line if there
  817. are multiple basic blocks that end on that line. In this case, the
  818. branches and calls are each given a number. There is no simple way to map
  819. these branches and calls back to source constructs. In general, though,
  820. the lowest numbered branch or call will correspond to the leftmost construct
  821. on the source line.
  822. .PP
  823. For a branch, if it was executed at least once, then a percentage
  824. indicating the number of times the branch was taken divided by the
  825. number of times the branch was executed will be printed. Otherwise, the
  826. message \*(L"never executed\*(R" is printed.
  827. .PP
  828. For a call, if it was executed at least once, then a percentage
  829. indicating the number of times the call returned divided by the number
  830. of times the call was executed will be printed. This will usually be
  831. 100%, but may be less for functions that call \f(CW\*(C`exit\*(C'\fR or \f(CW\*(C`longjmp\*(C'\fR,
  832. and thus may not return every time they are called.
  833. .PP
  834. The execution counts are cumulative. If the example program were
  835. executed again without removing the \fI.gcda\fR file, the count for the
  836. number of times each line in the source was executed would be added to
  837. the results of the previous run(s). This is potentially useful in
  838. several ways. For example, it could be used to accumulate data over a
  839. number of program runs as part of a test verification suite, or to
  840. provide more accurate long-term information over a large number of
  841. program runs.
  842. .PP
  843. The data in the \fI.gcda\fR files is saved immediately before the program
  844. exits. For each source file compiled with \fB\-fprofile\-arcs\fR, the
  845. profiling code first attempts to read in an existing \fI.gcda\fR file; if
  846. the file doesn't match the executable (differing number of basic block
  847. counts) it will ignore the contents of the file. It then adds in the
  848. new execution counts and finally writes the data to the file.
  849. .SS "Using \fBgcov\fP with \s-1GCC\s0 Optimization"
  850. .IX Subsection "Using gcov with GCC Optimization"
  851. If you plan to use \fBgcov\fR to help optimize your code, you must
  852. first compile your program with two special \s-1GCC\s0 options:
  853. \&\fB\-fprofile\-arcs \-ftest\-coverage\fR. Aside from that, you can use any
  854. other \s-1GCC\s0 options; but if you want to prove that every single line
  855. in your program was executed, you should not compile with optimization
  856. at the same time. On some machines the optimizer can eliminate some
  857. simple code lines by combining them with other lines. For example, code
  858. like this:
  859. .PP
  860. .Vb 4
  861. \& if (a != b)
  862. \& c = 1;
  863. \& else
  864. \& c = 0;
  865. .Ve
  866. .PP
  867. can be compiled into one instruction on some machines. In this case,
  868. there is no way for \fBgcov\fR to calculate separate execution counts
  869. for each line because there isn't separate code for each line. Hence
  870. the \fBgcov\fR output looks like this if you compiled the program with
  871. optimization:
  872. .PP
  873. .Vb 4
  874. \& 100: 12:if (a != b)
  875. \& 100: 13: c = 1;
  876. \& 100: 14:else
  877. \& 100: 15: c = 0;
  878. .Ve
  879. .PP
  880. The output shows that this block of code, combined by optimization,
  881. executed 100 times. In one sense this result is correct, because there
  882. was only one instruction representing all four of these lines. However,
  883. the output does not indicate how many times the result was 0 and how
  884. many times the result was 1.
  885. .PP
  886. Inlineable functions can create unexpected line counts. Line counts are
  887. shown for the source code of the inlineable function, but what is shown
  888. depends on where the function is inlined, or if it is not inlined at all.
  889. .PP
  890. If the function is not inlined, the compiler must emit an out of line
  891. copy of the function, in any object file that needs it. If
  892. \&\fIfileA.o\fR and \fIfileB.o\fR both contain out of line bodies of a
  893. particular inlineable function, they will also both contain coverage
  894. counts for that function. When \fIfileA.o\fR and \fIfileB.o\fR are
  895. linked together, the linker will, on many systems, select one of those
  896. out of line bodies for all calls to that function, and remove or ignore
  897. the other. Unfortunately, it will not remove the coverage counters for
  898. the unused function body. Hence when instrumented, all but one use of
  899. that function will show zero counts.
  900. .PP
  901. If the function is inlined in several places, the block structure in
  902. each location might not be the same. For instance, a condition might
  903. now be calculable at compile time in some instances. Because the
  904. coverage of all the uses of the inline function will be shown for the
  905. same source lines, the line counts themselves might seem inconsistent.
  906. .PP
  907. Long-running applications can use the \f(CW\*(C`_\|_gcov_reset\*(C'\fR and \f(CW\*(C`_\|_gcov_dump\*(C'\fR
  908. facilities to restrict profile collection to the program region of
  909. interest. Calling \f(CW\*(C`_\|_gcov_reset(void)\*(C'\fR will clear all profile counters
  910. to zero, and calling \f(CW\*(C`_\|_gcov_dump(void)\*(C'\fR will cause the profile information
  911. collected at that point to be dumped to \fI.gcda\fR output files.
  912. Instrumented applications use a static destructor with priority 99
  913. to invoke the \f(CW\*(C`_\|_gcov_dump\*(C'\fR function. Thus \f(CW\*(C`_\|_gcov_dump\*(C'\fR
  914. is executed after all user defined static destructors,
  915. as well as handlers registered with \f(CW\*(C`atexit\*(C'\fR.
  916. If an executable loads a dynamic shared object via dlopen functionality,
  917. \&\fB\-Wl,\-\-dynamic\-list\-data\fR is needed to dump all profile data.
  918. .SH "SEE ALSO"
  919. .IX Header "SEE ALSO"
  920. \&\fBgpl\fR\|(7), \fBgfdl\fR\|(7), \fBfsf\-funding\fR\|(7), \fBgcc\fR\|(1) and the Info entry for \fIgcc\fR.
  921. .SH "COPYRIGHT"
  922. .IX Header "COPYRIGHT"
  923. Copyright (c) 1996\-2018 Free Software Foundation, Inc.
  924. .PP
  925. Permission is granted to copy, distribute and/or modify this document
  926. under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.3 or
  927. any later version published by the Free Software Foundation; with the
  928. Invariant Sections being \*(L"\s-1GNU\s0 General Public License\*(R" and \*(L"Funding
  929. Free Software\*(R", the Front-Cover texts being (a) (see below), and with
  930. the Back-Cover Texts being (b) (see below). A copy of the license is
  931. included in the \fBgfdl\fR\|(7) man page.
  932. .PP
  933. (a) The \s-1FSF\s0's Front-Cover Text is:
  934. .PP
  935. .Vb 1
  936. \& A GNU Manual
  937. .Ve
  938. .PP
  939. (b) The \s-1FSF\s0's Back-Cover Text is:
  940. .PP
  941. .Vb 3
  942. \& You have freedom to copy and modify this GNU Manual, like GNU
  943. \& software. Copies published by the Free Software Foundation raise
  944. \& funds for GNU development.
  945. .Ve