NAME
Devel::XSCover::DB - the C coverage written into Devel::Cover's database
SYNOPSIS
use Devel::XSCover::DB;
my $writer = Devel::XSCover::DB->new(dir => '.', db => 'cover_db');
my ($files, $generated) = $writer->merge(@objects);
my $entries = $writer->entries($files, $generated, @maps);
my $run = $writer->write($entries);
DESCRIPTION
Turns what the gcov reader and the XS map found into one Devel::Cover run with three criteria for every C and XS file, statements, branches and subroutines, and conditions too when the compiler reported them. cover then reads it beside the Perl runs of the same test run.
METHODS
new
my $writer = Devel::XSCover::DB->new(%options);
Options: dir, db (relative to dir unless absolute), macro_branches (keep the branches of macros, see entries), dry and silent.
merge
my ($files, $generated) = $writer->merge(@objects);
Merges the objects of the reader into one hash of files and one of generated files. A file seen from several objects, as a header with inline functions is, becomes one entry: the union of its lines with the counts summed, its functions summed by name and line, and the arms of its blocks summed where the same block was seen twice.
entries
my $entries = $writer->entries($files, $generated, @maps);
The criteria per file. Every executable line is a statement. A block of two arms is one branch with the source line as its text, the arms in gcov's order. A block of more arms is one branch per arm, arm k of N, each the arm against the sum of the others. A block on a line whose text holds no decision (no if, else, while, for, do, switch, ?, && or || outside comments) is a macro's own, as GvSVn or SvTRUE expand to, and is left out unless macro_branches is set: nothing in the source can take its other arm. Every C function is a subroutine on its first line under its C name. An XSUB is a subroutine on its declaration line in the XS under each of its Perl names, with the count of its wrapper from the generated C. A decision that gcc 14's condition coverage reported becomes one condition per term, term k of the source line, with two counts: whether the term's true outcome and whether its false outcome each decided the result at least once.
write
my $run = $writer->write($entries);
Writes one run under the database, with the file paths relative to dir as cover expects them, and returns a hash with the run's path and the counts of files, statements, branches and subroutines written. A file that is not under dir is skipped with a warning.