Forrest logo
back to the gcov tool

gcov:tldr:3fad2

gcov: Write file level as well as function level summaries.
$ gcov --function-summaries ${filename-cpp}
try on your machine

The command "gcov --function-summaries ${filename-cpp}" is used to generate a code coverage report using the Gcov tool.

Gcov is a profiling tool available in most GNU systems. It is typically used alongside with the GNU Compiler Collection (GCC) to measure the code coverage of programs during testing. Code coverage measures the degree to which source code has been executed by a test suite.

In this command, "${filename-cpp}" is a placeholder that represents the name of a C++ source file without the file extension. It should be replaced with the actual name of the C++ source file. For example, if the file is named "example.cpp", the command would be "gcov --function-summaries example.cpp".

The "--function-summaries" flag tells gcov to provide a summary of the functions and their coverage within the specified C++ source file. It will display the number of times each function is called, along with the percentage of function calls covered by executed test cases.

When executed, this command will produce a coverage report file with the ".gcov" extension, containing a detailed analysis of the functions and their coverage within the source file specified.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the gcov tool