1
g++ (Ubuntu 9.4.0-1ubuntu1~18.04) 9.4.0
gcov (Ubuntu 9.4.0-1ubuntu1~18.04) 9.4.0
lcov: LCOV version 1.13
  1. g++ -g -O0 --coverage main.cpp -o main
  2. ./main
  3. lcov -t "main" -o main.info -c -d . --gcov-tool gcov-9

The output:

Capturing coverage data from .
Found gcov version: 9.4.0
Scanning . for .gcda files ...
Found 1 data files in .
Processing main.gcda
geninfo: WARNING: /home/home/main.gcno: Overlong record at end of file!
geninfo: WARNING: cannot find an entry for main.cpp.gcov in .gcno file, skipping file!
Finished .info-file creation
  1. genhtml -o report main.info

The output:

genhtml: ERROR: no valid records found in tracefile main.info
vamirio-chan
  • 339
  • 1
  • 13

1 Answers1

0

So far I haven't managed to utilize lcov. Yet I've found a solution that works for me.

  1. Install gcovr https://github.com/gcovr/gcovr
  2. Build your application with -fprofile-arcs -ftest-coverage -g -O0
  3. Link gcov to your executable/libs (-lgcov)
  4. Create .gcov files with gcov-9 -b -l -p -c *.gcno command. (If you're using cmake you will need to run this command recursively through all CMakeFiles/{all subfolders}.dir/src/* directories)
  5. gcovr {rootDir} -r {sourceDir} -g -k --html --html-details -o tp.html

rootDir - the directory you can access .gcov from. sourceDir - sources that shall be in tp.html report

vamirio-chan
  • 339
  • 1
  • 13
  • P.s. Thanks to these answers: https://stackoverflow.com/a/43586279/13024483 https://stackoverflow.com/a/3755038/13024483 https://stackoverflow.com/a/46232989/13024483 – vamirio-chan Oct 19 '21 at 18:29