
{"id":11745,"date":"2013-07-24T21:08:56","date_gmt":"2013-07-24T21:08:56","guid":{"rendered":"http:\/\/www.beautifulwork.org\/?p=11745"},"modified":"2013-07-24T21:08:56","modified_gmt":"2013-07-24T21:08:56","slug":"gcov-test-coverage-program","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2013\/07\/24\/gcov-test-coverage-program\/","title":{"rendered":"What is gcov  which comes with GCC ?"},"content":{"rendered":"<p><u>ABOUT gcov<\/u><\/p>\n<pre>\nGcov is a source code coverage analysis and statement-by-statement profiling tool. Gcov generates exact counts of the number of times each statement in a program is executed and annotates source code to add instrumentation. Gcov comes as a standard utility with the GNU Compiler Collection (GCC) suite.[1]\n\nThe gcov utility gives information on how often a program executes segments of code.[2] It produces a copy of the source file, annotated with execution frequencies. The gcov utility does not produce any time-based data and works only on code compiled with the GCC suite. The manual claims it is not compatible with any other profiling or test coverage mechanism,[3] but it works with llvm-generated files, too.\n<\/pre>\n<p><u>A TYPICAL SHELL SESSION<\/u><br \/>\n[bash]<br \/>\n$ls<br \/>\nloop.c<br \/>\n$gcc -fprofile-arcs -ftest-coverage loop.c<br \/>\n$ls<br \/>\na.out  loop.c  loop.gcno<br \/>\n$.\/a.out<br \/>\n^C<br \/>\n$ls<br \/>\na.out  loop.c  loop.gcno<br \/>\n$gcov loo<br \/>\nloop.c     loop.gcno<br \/>\n$gcov loop.c<br \/>\nloop.gcda:cannot open data file, assuming not executed<br \/>\nFile &#8216;loop.c&#8217;<br \/>\nNo executable lines<br \/>\nRemoving &#8216;loop.c.gcov&#8217;<\/p>\n<p>$cat loo<br \/>\nloop.c     loop.gcno<br \/>\n$cat loop.c<br \/>\nmain()<br \/>\n{<br \/>\nfor (;;);<br \/>\n}<\/p>\n<p>$cp \/home\/jeffrin\/loop.c .<br \/>\n$cat loop.c<br \/>\nmain()<br \/>\n{<br \/>\nprintf(&quot;hello world&quot;);<br \/>\n}<\/p>\n<p>$gcc -fprofile-arcs -ftest-coverage loop.c<br \/>\nloop.c: In function \u2018main\u2019:<br \/>\nloop.c:3:1: warning: incompatible implicit declaration of built-in function \u2018printf\u2019 [enabled by default]<br \/>\n$.\/a.out<br \/>\nhello world$<br \/>\n$gcov loop.c<br \/>\nFile &#8216;loop.c&#8217;<br \/>\nLines executed:100.00% of 3<br \/>\nCreating &#8216;loop.c.gcov&#8217;<\/p>\n<p>$cat loop.c.gcov<br \/>\n        -:    0:Source:loop.c<br \/>\n        -:    0:Graph:loop.gcno<br \/>\n        -:    0:Data:loop.gcda<br \/>\n        -:    0:Runs:1<br \/>\n        -:    0:Programs:1<br \/>\n        1:    1:main()<br \/>\n        -:    2:{<br \/>\n        1:    3:printf(&quot;hello world&quot;);<br \/>\n        1:    4:}<br \/>\n        -:    5:<br \/>\n$<\/p>\n<p>[\/bash]<br \/>\nLINK<br \/>\n<a href=\"https:\/\/en.wikipedia.org\/wiki\/Gcov\">https:\/\/en.wikipedia.org\/wiki\/Gcov<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ABOUT gcov Gcov is a source code coverage analysis and statement-by-statement profiling tool. Gcov generates exact counts of the number of times each statement in a program is executed and annotates source code to add instrumentation. Gcov comes as a standard utility with the GNU Compiler Collection (GCC) suite.[1] The gcov utility gives information on &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2013\/07\/24\/gcov-test-coverage-program\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;What is gcov  which comes with GCC ?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[83],"tags":[552,596,810],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/11745"}],"collection":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/comments?post=11745"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/11745\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=11745"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=11745"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=11745"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}