Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-26102

dgcov: add support for *.gcda.gcov.json.gz files of gcov 9.1+

Details

    Description

      1. dgcov should be supported with gcc version gcc 4.9.4+ since there is -i option introduced.
      2. json format found from here that is introduced with 9.1.0. Looking from all release changes for 9.1.0

      The following improvements to the gcov command-line utility have been made.
       
      The gcov tool received a new option --use-hotness-colors (-q) that can provide perf-like coloring of hot functions.
      The gcov tool has changed its intermediate format to a new JSON format.
      

      and seems that in that version intermediate format was deprecated.
      Additional links:
      [1] Zulip analysis
      [2] Support GCOV intermediate format

      Attachments

        Issue Links

          Activity

            Sorry, I haven't read perldoc. Reading/testing. Thanks.

            anel Anel Husakovic added a comment - Sorry, I haven't read perldoc . Reading/testing. Thanks.

            Why are you even looking at json_pp? Just use JSON::PP module. Like this:

            #!/usr/bin/perl -l
             
            use IO::Uncompress::Gunzip qw(gunzip $GunzipError);
            use JSON::PP;
             
            my $js;
            gunzip $ARGV[0] => \$js or die "gunzip($ARGV[0]): $GunzipError";
            my $obj=decode_json $js;
             
            for my $file (@{$obj->{files}}) {
              print "file: $file->{file}";
              for my $fn (@{$file->{functions}}) {
                print "..function: ", $fn->{demangled_name} || $fn-{name};
              }
            }
            

            This is a complete demo program, if you run it with a gcda.gcov.json.gz file as an argument, it'll print you all functions in all files in this json file. For example,

            $ ./a.pl gen_lex_token.cc.gcda.gcov.json.gz 
            file: sql/gen_lex_token.cc
            ..function: set_token(int, char const*)
            ..function: set_start_expr_token(int)
            ..function: compute_tokens()
            ..function: print_tokens()
            ..function: main
            

            serg Sergei Golubchik added a comment - Why are you even looking at json_pp ? Just use JSON::PP module. Like this: #!/usr/bin/perl -l   use IO::Uncompress::Gunzip qw(gunzip $GunzipError ); use JSON::PP;   my $js ; gunzip $ARGV [0] => \ $js or die "gunzip($ARGV[0]): $GunzipError" ; my $obj =decode_json $js ;   for my $file (@{ $obj ->{files}}) { print "file: $file->{file}" ; for my $fn (@{ $file ->{functions}}) { print "..function: " , $fn ->{demangled_name} || $fn -{name}; } } This is a complete demo program, if you run it with a gcda.gcov.json.gz file as an argument, it'll print you all functions in all files in this json file. For example, $ ./a.pl gen_lex_token.cc.gcda.gcov.json.gz file: sql/gen_lex_token.cc ..function: set_token(int, char const*) ..function: set_start_expr_token(int) ..function: compute_tokens() ..function: print_tokens() ..function: main

            Thanks for help serg it helped me a lot.
            New patch: 203aa38f9b6606d
            Example of the result:

            $./mtr --gcov is_check_constraints --record && cat var/last_changes.dgcov
             
            *********************
            dgcov sql/sql_show.cc
            *********************
            @@ +6601,7 @@ static int get_check_constraints_record(THD *thd, TABLE_LIST *tables,
                     : 6601:      }
                     : 6602:#endif
                     : 6603:      Virtual_column_info *check= tables->table->check_constraints[i];
                   44: 6605:      table->field[0]->store(STRING_WITH_LEN("definition"), system_charset_info);
                     : 6606:      table->field[3]->store(check->name.str, check->name.length,
                     : 6607:                             system_charset_info);
            

            anel Anel Husakovic added a comment - Thanks for help serg it helped me a lot. New patch: 203aa38f9b6606d Example of the result: $./mtr --gcov is_check_constraints --record && cat var/last_changes.dgcov   ********************* dgcov sql/sql_show.cc ********************* @@ +6601,7 @@ static int get_check_constraints_record(THD *thd, TABLE_LIST *tables, : 6601: } : 6602:#endif : 6603: Virtual_column_info *check= tables->table->check_constraints[i]; 44: 6605: table->field[0]->store(STRING_WITH_LEN("definition"), system_charset_info); : 6606: table->field[3]->store(check->name.str, check->name.length, : 6607: system_charset_info);

            Hi Serg,
            new patch 85aa3f8cf66per your review .

            anel Anel Husakovic added a comment - Hi Serg, new patch 85aa3f8cf66 per your review .
            anel Anel Husakovic added a comment - - edited

            Test of patch - with appended commit message (about usage of gcc version <9 and >=9 - noted error in regex - so new patch will be)

            • gcc version < 9 (gcov uses -i format as a file)

              # -DENABLE_GCOV=ON -DCMAKE_\{C_COMPILER=gcc,CXX_COMPILER=g++\}-7
              $ git cherry-pick 25d66172f4a2ba1c8fd25a68032e3d9b782e6adb  # note bb-10.2-anel-MDEV-18284-json_compact commit
              $ cmake --build . -- -j8
              $ ./mtr --gcov func_json
              $ cat var/last_changes.dgcov 
              ****************
              dgcov sql/item.h
              ****************
              @@ +4564,7 @@ class Item_ref :public Item_ident
                       : 4564:  {
                       : 4565:    return ref ? (*ref)->real_item() : this;
                       : 4566:  }
                      1: 4567:  bool is_json_type() { return (*ref)->is_json_type(); }
                       : 4568:  bool walk(Item_processor processor, bool walk_subquery, void *arg)
                       : 4569:  { 
                       : 4570:    if (ref && *ref)
              

            • gcov version 9 (gcc version 9 too)

               
              $ sudo update-alternatives --display gcc
              $ sudo update-alternatives --config gcc #(to 9)
              $ gcc --version
              gcc (Ubuntu 9.4.0-1ubuntu1~18.04) 9.4.0
              $ g++ --version
              g++ (Ubuntu 9.4.0-1ubuntu1~18.04) 9.4.0
              # Remove old gcov (symlink to gcov-7)
              $ sudo rm /usr/bin/gcov
              # Make it symlink to gcov-9
              $ sudo ln -s /usr/bin/gcov-9 /usr/bin/gcov
               
              # Remove old files
              $ git clean -dffx
              $ cmake . -DCMAKE_BUILD_TYPE=Debug -DPLUGIN_{ARCHIVE,TOKUDB,MROONGA,OQGRAPH,ROCKSDB,CONNECT,PERFSCHEMA,SPIDER,SPHINX}=NO -DENABLE_GCOV=ON -DCMAKE_\{C_COMPILER=gcc,CXX_COMPILER=g++\}-9
              $ cmake --build . -- -j8
               
              $ git cherry-pick 25d66172f4a2ba1c8fd25a68032e3d9b782e6adb  # note bb-10.2-anel-MDEV-18284-json_compact commit
              $ ./mtr --gcov func_json
              # Example of generated file: ./mysys/CMakeFiles/mysys.dir/list.c.gcda.gcov.json.gz
              $ cat var/last_changes.dgcov 
              ****************
              dgcov sql/item.h
              ****************
              @@ +4564,7 @@ class Item_ref :public Item_ident
                       : 4564:  {
                       : 4565:    return ref ? (*ref)->real_item() : this;
                       : 4566:  }
                      1: 4567:  bool is_json_type() { return (*ref)->is_json_type(); }
                       : 4568:  bool walk(Item_processor processor, bool walk_subquery, void *arg)
                       : 4569:  { 
                       : 4570:    if (ref && *ref)
              

            Same result as above.

            New patch (removed unused line) : 5599795abe1faee79 serg

            anel Anel Husakovic added a comment - - edited Test of patch - with appended commit message (about usage of gcc version <9 and >=9 - noted error in regex - so new patch will be) gcc version < 9 ( gcov uses -i format as a file) # -DENABLE_GCOV=ON -DCMAKE_\{C_COMPILER=gcc,CXX_COMPILER=g++\}-7 $ git cherry-pick 25d66172f4a2ba1c8fd25a68032e3d9b782e6adb # note bb-10.2-anel-MDEV-18284-json_compact commit $ cmake --build . -- -j8 $ . /mtr --gcov func_json $ cat var /last_changes .dgcov **************** dgcov sql /item .h **************** @@ +4564,7 @@ class Item_ref :public Item_ident : 4564: { : 4565: return ref ? (*ref)->real_item() : this; : 4566: } 1: 4567: bool is_json_type() { return (*ref)->is_json_type(); } : 4568: bool walk(Item_processor processor, bool walk_subquery, void *arg) : 4569: { : 4570: if (ref && *ref) gcov version 9 ( gcc version 9 too)   $ sudo update-alternatives --display gcc $ sudo update-alternatives --config gcc #(to 9) $ gcc --version gcc (Ubuntu 9.4.0-1ubuntu1~18.04) 9.4.0 $ g++ --version g++ (Ubuntu 9.4.0-1ubuntu1~18.04) 9.4.0 # Remove old gcov (symlink to gcov-7) $ sudo rm /usr/bin/gcov # Make it symlink to gcov-9 $ sudo ln -s /usr/bin/gcov-9 /usr/bin/gcov   # Remove old files $ git clean -dffx $ cmake . -DCMAKE_BUILD_TYPE=Debug -DPLUGIN_{ARCHIVE,TOKUDB,MROONGA,OQGRAPH,ROCKSDB,CONNECT,PERFSCHEMA,SPIDER,SPHINX}=NO -DENABLE_GCOV=ON -DCMAKE_\{C_COMPILER=gcc,CXX_COMPILER=g++\}-9 $ cmake --build . -- -j8   $ git cherry-pick 25d66172f4a2ba1c8fd25a68032e3d9b782e6adb # note bb-10.2-anel-MDEV-18284-json_compact commit $ . /mtr --gcov func_json # Example of generated file: ./mysys/CMakeFiles/mysys.dir/list.c.gcda.gcov.json.gz $ cat var /last_changes .dgcov **************** dgcov sql /item .h **************** @@ +4564,7 @@ class Item_ref :public Item_ident : 4564: { : 4565: return ref ? (*ref)->real_item() : this; : 4566: } 1: 4567: bool is_json_type() { return (*ref)->is_json_type(); } : 4568: bool walk(Item_processor processor, bool walk_subquery, void *arg) : 4569: { : 4570: if (ref && *ref) Same result as above. New patch (removed unused line) : 5599795abe1faee79 serg

            People

              anel Anel Husakovic
              anel Anel Husakovic
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.