User Tools

Site Tools


developersguide:gcov

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
developersguide:gcov [2016/09/25 08:42]
dcvmoole a full page update to reflect the current (working!) state
developersguide:gcov [2016/09/25 08:48]
dcvmoole might as well finish each sentence, oops.
Line 33: Line 33:
 With crosscompilation,​ one will typically want to copy the .gcda files back to the crosscompilation environment,​ and analyze the results from there. Note that in this case, the .gcno files will also not be located in the same directory as the source code, but rather in its object directory. With crosscompilation,​ one will typically want to copy the .gcda files back to the crosscompilation environment,​ and analyze the results from there. Note that in this case, the .gcno files will also not be located in the same directory as the source code, but rather in its object directory.
  
-The LLVM llvm-cov(1) utility can be used to produce meaningful output from the combination of the source, .gcno, and .gcda files. The llvm-cov(1) utility itself has been modified heavily in recent times, which means that different syntax ​+The LLVM llvm-cov(1) utility can be used to produce meaningful output from the combination of the source, .gcno, and .gcda files. The llvm-cov(1) utility itself has been modified heavily in recent times, which means that different syntax ​is needed for different LLVM versions.
  
 On systems with LLVM 3.4 (as of writing, the LLVM version on native MINIX3), one can get a view of the source code of, say, module "​foo.c"​ with per-line coverage information using the following command, dumped to stdout: On systems with LLVM 3.4 (as of writing, the LLVM version on native MINIX3), one can get a view of the source code of, say, module "​foo.c"​ with per-line coverage information using the following command, dumped to stdout:
Line 39: Line 39:
 > llvm-cov -gcno=foo.gcno -gcda=foo.gcda > llvm-cov -gcno=foo.gcno -gcda=foo.gcda
  
-With later LLVM versions, ​a different syntax is needed to achieve ​the same results:+With later LLVM versions, the following syntax can be used instead:
  
 > llvm-cov gcov [-o path/​to/​gcno/​files] foo.c > llvm-cov gcov [-o path/​to/​gcno/​files] foo.c
  
-This will then generate a file "​foo.c.gcov"​ with the same per-line coverage output.+This will generate a file "​foo.c.gcov"​ with the same per-line coverage output.
  
 The output prefixes each source code line with a counter that shows the number of times the corresponding basic block has been invoked, or "#####"​ if the basic block has not been invoked yet. The newer llvm-cov has other features that may be interesting as well. For even fancier things such as generating webpages from the results, see various webpages on how to use LLVM GCOV. The output prefixes each source code line with a counter that shows the number of times the corresponding basic block has been invoked, or "#####"​ if the basic block has not been invoked yet. The newer llvm-cov has other features that may be interesting as well. For even fancier things such as generating webpages from the results, see various webpages on how to use LLVM GCOV.
developersguide/gcov.txt · Last modified: 2016/09/25 08:48 by dcvmoole