Commit 6638cf2e authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-20787 Script dgcov.pl does not work

For every file.gcda file, gcov <7.x created file.cc.gcda.gcov.
While gcov 7.x and 8.x create file.cc.gcov
And sometimes otherfile.h.gcov or otherfile.ic.gcov, for included files.

(gcov 9.x+ creates .json.gz files, see MDEV-26102)

So, we use `gcov -l` that will create file.cc.gcda##file.cc.gcov,
file.cc.gcda##otherfile.h.gcov, etc. And we search and parse all
those file.cc.gcda*.gcov files.
parent 0151590d
...@@ -155,32 +155,34 @@ END ...@@ -155,32 +155,34 @@ END
sub gcov_one_file { sub gcov_one_file {
return unless /\.gcda$/; return unless /\.gcda$/;
unless ($opt_skip_gcov) { unless ($opt_skip_gcov) {
$cmd= "gcov -i '$_' 2>/dev/null >/dev/null"; $cmd= "gcov -il '$_' 2>/dev/null >/dev/null";
print STDERR ++$file_no,"\r" if not $opt_verbose and -t STDERR; print STDERR ++$file_no,"\r" if not $opt_verbose and -t STDERR;
logv "Running: $cmd"; logv "Running: $cmd";
system($cmd)==0 or die "system($cmd): $? $!"; system($cmd)==0 or die "system($cmd): $? $!";
} }
# now, read the generated file # now, read the generated file
open FH, '<', "$_.gcov" or die "open(<$_.gcov): $!"; for my $gcov_file (<$_*.gcov>) {
my $fname; open FH, '<', "$gcov_file" or die "open(<$gcov_file): $!";
while (<FH>) { my $fname;
chomp; while (<FH>) {
if (/^function:/) { chomp;
next; if (/^function:/) {
} next;
if (/^file:/) { }
$fname=realpath($'); if (/^file:/) {
next; $fname=realpath($');
} next;
next if /^lcount:\d+,-\d+/; # whatever that means }
unless (/^lcount:(\d+),(\d+)/ and $fname) { next if /^lcount:\d+,-\d+/; # whatever that means
warn "unknown line '$_' after running '$cmd'"; unless (/^lcount:(\d+),(\d+)/ and $fname) {
next; warn "unknown line '$_' in $gcov_file";
next;
}
$cov{$fname}->{$1}+=$2;
} }
$cov{$fname}->{$1}+=$2; close(FH);
} }
close(FH);
} }
sub write_coverage { sub write_coverage {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment