GPS is fitted with a strong integration of Gcov, the GNU code coverage utility.
Code coverage information can be computed from, loaded and visualized in GPS. This can be done file by file, for each files of the current project, project by project (in case of dependencies) or for the entire project hierarchy currently used in GPS.
Once computed then loaded, the coverage information is summarized in a graphical report (shaped as a tree-view with percentage bars for each item) and used to decorate source code through mechanisms such as line highlighting or coverage annotations.
All the coverage related operations are reachable via the
Tools->Coverage
menu.
In order to be loaded in GPS, the coverage information need to be computed
before, using the Tools->Coverage->Gcov->Compute coverage files
menu
for instance.
At each attempt, GPS automatically tries to load the needed information and
reports errors for missing or corrupted .gcov
files.
To be able to produce coverage information from Gcov, your project must have
been compiled with the -fprofile-arcs
and -ftest-coverage
"
switches, respectively "Instrument arcs" and "Code coverage" entries in
The Project Properties Editor, and run once.
The Tools->Coverage
menu have an incremental set of entries,
depending on the context.
Coverage->Gcov->Compute coverage files
Generates the .gcov
files of current and properly compiled and run
projects.
Coverage->Gcov->Remove coverage files
Deletes all the .gcov
of current projects.
Coverage->Show report
Open a new window summarizing the coverage information currently loaded in GPS.
Coverage->Load data for all projects
Load or re-load the coverage information of every projects and subprojects.
Coverage->Load data for project XXX
Load or re-load the coverage information of the project XXX
.
Coverage->Load data for xxxxxxxx.xxx
Load or re-load the coverage information of the specified source file.
Coverage->Clear coverage from memory
Drop every coverage information loaded in GPS.
When clicking on a project, file or subprogram entity (including the entities
listed in the coverage report), you have access to a Coverage
submenu.
These submenus contain the following entries, adapted to the context related element. For instance, if you click on a file, you will have:
Coverage->Show coverage information
Append an annotation column to the left side of the current source editor. This column indicates which lines are covered and which aren’t. Unexecuted lines are also listed in the The Locations View.
Coverage->Hide coverage information
Withdraw from the current source editor a previously set coverage annotation column and clear The Locations View from the eventually listed uncovered lines.
Coverage->Load data for xxxxxxxx.xxx
Load or re-load the coverage information of the specified source file.
Coverage->Remove data of xxxxxxxx.xxx
Remove the coverage information of the specified source file from GPS memory.
Coverage->Show Coverage report
Open a new window summarizing the coverage information. (This entry appears only if the contextual menu has been created from outside of the Coverage Report.)
When coverage information are loaded into GPS, a graphical report of coverage is displayed.
This report contains a tree of Projects, Files and Subprograms with corresponding coverage information for each node in sided columns.
The contextual menus generated on this widget contain, in addition to the regular entries, some specific Coverage Report entries.
These entries allow you to expand or fold the tree, and also to display flat lists of files or subprograms instead of the tree. A flat list of file will look like:
GPS and Gcov both support many different programming languages, and so code coverage features are available in GPS for many languages. But, note that subprogram coverage details are not available for every supported languages.
To finish, note that if you change the current main project in GPS, using the
Project->Open
menu for instance, you will also drop every loaded
coverage information as they are related to the working project.