Coverage analysis is the gathering of information about which points in
the code, or coverage sites, were executed, and how many times,
during a particular run of the program. It is available as of release
4.2, for compiled as well as interpreted code, provided that such code was
loaded with the
source_info Prolog flag switched on. In fact, it
uses the same underlying support as execution profiling: while the
program is running with execution profiling switched on, the data
accumulated can be used for both purposes. Roughly, coverage sites
correspond to points in the code at which the debugger would stop in
trace mode, plus one site at entry to every clause. A typical
query pattern is:
| ?- [Load some code.] | ?- prolog_flag(profiling,_,on). | ?- [Run some queries.] | ?- prolog_flag(profiling,_,off). | ?- print_coverage.
coverage_data/1 makes the accumulated data
available as a Prolog term. The predicate
prints the execution coverage in a hierarchical format. It can also be
given an argument which should be of the same type as the output of
The collected coverage information can be presented by the SICStus
Prolog IDE, SPIDER (see SICStus Prolog IDE).
The Emacs interface also has commands for
code coverage highlighting of source code buffers (see Usage).
For the details, see the respective reference page.
profile_reset since release 4.2,development
Resets all profiling and coverage data. See mpg-ref-profile_reset.
coverage_data(-Data) since release 4.2,development
Data is the coverage data accumulated so far. See mpg-ref-coverage_data.
print_coverage since release 4.2,development
print_coverage(+Data) since release 4.2,development
The coverage data Data is displayed in a hierarchical format. Data defaults to the profiling data accumulated so far. See mpg-ref-print_coverage.