← Back to team overview

maria-developers team mailing list archive

Re: 203aa38f9b6: MDEV-26102: gcov 9.1 doesn't support intermediate format any more, but json instead - refactoring needed

 

Hi, Anel!

On Jul 28, Anel Husakovic wrote:
> revision-id: 203aa38f9b6 (mariadb-10.2.39-96-g203aa38f9b6)
> parent(s): afe00bb7cce
> author: Anel Husakovic
> committer: Anel Husakovic
> timestamp: 2021-07-27 16:09:41 +0200
> message:
> 
> MDEV-26102: gcov 9.1 doesn't support intermediate format any more, but json instead - refactoring needed

I've renamed the MDEV to have a shorter title, use the new one in your
next commit

> 
> Reviewed by: serg@xxxxxxxxxxx

that's not right, I haven't reviewed it yet :)

> diff --git a/mysql-test/dgcov.pl b/mysql-test/dgcov.pl
> index 2c00c64d1ff..e2aadec33e0 100755
> --- a/mysql-test/dgcov.pl
> +++ b/mysql-test/dgcov.pl
> @@ -25,6 +25,8 @@ use warnings;
>  use Getopt::Long;
>  use File::Find;
>  use Cwd qw/realpath/;
> +use IO::Uncompress::Gunzip qw(gunzip $GunzipError);
> +use JSON::PP;

move this down, dcgov should not try to load these modules for for gcc < 9

>  my $opt_verbose=0;
>  my $opt_generate;
> @@ -32,6 +34,7 @@ my $opt_help;
>  my $opt_purge;
>  my $opt_only_gcov;
>  my $opt_skip_gcov;
> +my $fname;

and this

>  
>  my %cov;
>  my $file_no=0;
> @@ -62,12 +65,15 @@ my $res;
>  my $cmd;
>  if ($opt_purge)
>  {
> -  $cmd= "find . -name '*.da' -o -name '*.gcda' -o -name '*.gcov' -o ".
> +  $cmd= "find . -name '*.da' -o -name '*.gcda*' -o -name '*.gcov' -o ".
>                 "-name '*.dgcov' | grep -v 'README\.gcov' | xargs rm -f ''";
>    logv "Running: $cmd";
>    system($cmd)==0 or die "system($cmd): $? $!";
>    exit 0;
>  }
> +
> +my $gcc_version= `gcc -dumpversion`;
> +$gcc_version=~ s/(\d).*$/$1/;

you don't need this second line, I suspect

>  
>  find(\&gcov_one_file, $root);
>  find(\&write_coverage, $root) if $opt_generate;
> @@ -162,6 +168,7 @@ sub gcov_one_file {
>    }
>  
>    # now, read the generated file
> +  if ($gcc_version <9){
>    for my $gcov_file (<$_*.gcov>) {
>      open FH, '<', "$gcov_file" or die "open(<$gcov_file): $!";
>      my $fname;
> @@ -183,6 +189,18 @@ sub gcov_one_file {
>        $cov{$fname}->{$1}+=$2;
>      }
>      close(FH);
> +    }
> +  }
> +  else {

put both `use` lines here

> +    my $gcov_file_json;
> +    gunzip "$_.gcov.json.gz" => \$gcov_file_json or die "gunzip($_.gcov.json.gz): $GunzipError";
> +    my $obj= decode_json $gcov_file_json;
> +    for my $file (@{$obj->{files}}) {
> +      $fname= $file->{file};

and write `my $fname` here

> +      for my $line (@{$file->{lines}}){
> +        $cov{$fname}->{$line->{line_number}}= $line->{count};

shouldn't it be += $line->{count} ?
The point is to accumulate all counters, see how it's done for non-json
intermediate format.

> +      }
> +    }
>    }
>  }
>  
> 
Regards,
Sergei
VP of MariaDB Server Engineering
and security@xxxxxxxxxxx


Follow ups