Search code examples
code-coveragegcovgcovr

How can we use gcovr with -g option?


How can we use gcovr with -g option? I've tried some commands but they all failed. I didn't get any errors but I didn't get the output that I've expected either. Documentation also does not give any examples:

http://gcovr.com/guide.html

Any ideas? Anyone used this option before?


Solution

  • As specified in user guide "-g" option is for directing gcovr to use existing gcov files instead of generating them again by using gcda nad gcno files.

    So the only thing to understand here is gcov files should be generated first by any of the possible methods.

    gcov files are files with ".gcov" extension and has the base name same as the corresponding c or c++ file. These files are annotated form of the relevant source files having symbols for signifying if the lines are executed, not executed, not a statement, branch etc. They can be generated using gcov (GNU GCC). Use this user guide to know how to do it.

    Or you can use gcovr once to generate a report and use "-k" option to direct gcovr to keep all the gcov files and then again use gcovr with "-g" option to use the existing gcov files instead of regenerating them. Use the same user guide provided in the question to understand the options better.