[MDEV-20787] Script dgcov.pl does not work Created: 2019-10-09  Updated: 2021-07-20  Resolved: 2021-07-20

Status: Closed
Project: MariaDB Server
Component/s: Scripts & Clients, Tests
Affects Version/s: 10.2, 10.3, 10.4, 10.5
Fix Version/s: 10.2.40, 10.3.31, 10.4.21, 10.5.12, 10.6.4

Type: Bug Priority: Major
Reporter: Varun Gupta (Inactive) Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: dgcov

Attachments: PNG File screenshot-1.png    
Issue Links:
Blocks
blocks MDBF-158 Gcov builder Open
Relates
relates to MDEV-25914 gcda data files are not created when ... Closed
relates to MDEV-25915 dgcov --generate error Closed
relates to MDEV-26102 dgcov: add support for *.gcda.gcov.js... Closed

 Description   

Compiling with:

cmake . -DCMAKE_BUILD_TYPE=Debug  -DENABLE_GCOV=ON
make -j10

Then running a test
./mtr --gcov main.subselect

==============================================================================
 
TEST                                      RESULT   TIME (ms) or COMMENT
--------------------------------------------------------------------------
 
worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 16000..16019
main.subselect                           [ pass ]   2364
--------------------------------------------------------------------------
The servers were restarted 0 times
Spent 2.364 of 5 seconds executing testcases
 
Completed: All 1 tests were successful.
 
Running dgcov
open(<string.c.gcda.gcov): No such file or directory at ./dgcov.pl line 165.

Then hit the above error.

Also checked dgcov works on 10.1.



 Comments   
Comment by Anel Husakovic [ 2019-10-10 ]

 ./mtr --gcov 

is basically doing

  ./dgcov.pl --purge

and

  ./dgcov.pl --generate > $opt_vardir/last_changes.dgcov

, where purge should delete all coverage information and prepare for new one.

In 10.2 running mtr doesn't show error at the end of test.
In 10.5 the error is showed (different one in my case - I'm supposing this is irrelevant), but the .gcov is generated in ./var/:

Error

open(<dbug.c.gcda.gcov): No such file or directory at ./dgcov.pl line 165.

If we run manually ./dgcov.pl without mtr (without purge) we will obtain the same error.
However, if we run ./dgcov.pl --purge error will not be shown and ./dgcov.pl -g > last_changes.gcov can be obtained.
I suppose the question is why ./dgcov.pl --purge doesn't work when used with ./mtr?

Comment by Anel Husakovic [ 2019-11-19 ]

Hi serg,
here is a patch with description in commit message. Seems jira is not picking up the branch per name.

Comment by Anel Husakovic [ 2020-10-05 ]

Hi serg, here is a new patch 8c34a242aa2d4e8e8.

Comment by Anel Husakovic [ 2020-10-22 ]

Hi serg,
I worked today on trying to make out-of-source possible and came to couple of problems.
First git: dgcov is using git commands and because of that I added option `basedir` to dgcov so I could change directory to handle git commands.
Second (unsolved): from mtr I run new process with system function. I created test file for experimenting and it works (calling multiple commands work), however I cannot call second time (from build_dir mtr is calling system(source_dir/mtr) -> which is calling system(dgcov) and it is not executed, why?
Third: For In-source builds with current patch I don't know what to expect (I know compared to 10.1 results, but didn't get the same), always I'm ending with empty `var/last_changes.`file and message on stdout for example for

./mtr --gcov grant5
,,,
unknown line 'lcount:297,0' after running 'gcov -i 'safe_process.cc.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 190, <FH> line 134.
unknown line 'lcount:299,0' after running 'gcov -i 'safe_process.cc.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 190, <FH> line 135.
unknown line 'lcount:300,0' after running 'gcov -i 'safe_process.cc.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 190, <FH> line 136.
unknown line 'lcount:303,0' after running 'gcov -i 'safe_process.cc.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 190, <FH> line 137.
unknown line 'lcount:305,0' after running 'gcov -i 'safe_process.cc.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 190, <FH> line 138.

I tried with staged and unstaged commit,with new commit to get something in last_changes, but don't know.
So .gcov files as inputs are supplied to the rest of the code, which is doing parsing/logic, but in case of logic and obtained result I'm bit confused.

There are 30 builds in buildbot queue so I don't want to pollute, so here is the new patch in my local repo:
https://github.com/an3l/server/tree/bb-10.2-MDEV-20787
Thanks.

Comment by Anel Husakovic [ 2020-10-24 ]

Forth problem (unsolved): cannot call script for out-of-source: so this line doesn't call dgcov.
Some solution may be to create a symlink of dgcov in build directory same as done for mtr.

I don't know how process flow in jira is going in this case, when I don't know what to do.
I will add `need_feedback` (to someone not only Serg and not to reporter).
If there exist some other label to reflect this scenario let me know.

So to summarize:

  • The last patch is addressing description of MDEV-20787 and 2 iterations of review,
  • but I don't see generated results with using dgcov and it is unclear me if the patch is good enough for general case,
  • in addition, addressing other problem with out-of-source work where I need some feedback.
  • Work stalled work because of above.
Comment by Sergei Golubchik [ 2020-10-30 ]

okay, let's ignore out-of-source problem for now. It could be a different MDEV, if needed. This one says "dgcov.pl does not work" and you make it working again. Out-of-source builds never worked with dgcov.pl, so fixing this would be out of scope of this one anyway.

Comment by Anel Husakovic [ 2020-11-03 ]

varun can you please try again this example on 10.2 and let me know which version of gcc, g++, gcov you are using?
I tried couple of examples to simulate again (note I had simulated previously but cannot now). In all cases var/last_changes file is obtained :

---------------------------------------------------------------------------------
 
/******* EXAMPLE 1: gcc,g++ 6.5; gcov 7.5 *******/
$ gcc --version
gcc (Ubuntu 6.5.0-2ubuntu1~18.04) 6.5.0 20181026
 
$ g++ --version
g++ (Ubuntu 6.5.0-2ubuntu1~18.04) 6.5.0 20181026
 
$ gcov --version
gcov (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
/*gcda files*/
./libmariadb/libmariadb/CMakeFiles/mariadb_obj.dir/ma_compress.c.gcda ## c files
./libmariadb/libmariadb/CMakeFiles/mariadb_obj.dir/ma_ll2str.c.gcda
./mysys/CMakeFiles/mysys.dir/mf_fn_ext.c.gcda
./scripts/CMakeFiles/comp_sql.dir/comp_sql.c.gcda
./dbug/CMakeFiles/dbug.dir/dbug.c.gcda
./sql/CMakeFiles/gen_lex_hash.dir/gen_lex_hash.cc.gcda ## cc files
./sql/CMakeFiles/gen_lex_token.dir/gen_lex_token.cc.gcda
 
/*gcno files*/
./libmariadb/libmariadb/CMakeFiles/mariadb_obj.dir/ma_tls.c.gcno ## c files
./libmariadb/libmariadb/CMakeFiles/mariadb_obj.dir/mariadb_stmt.c.gcno
./libmariadb/libmariadb/CMakeFiles/mariadb_obj.dir/mariadb_async.c.gcno
./libmariadb/libmariadb/CMakeFiles/mariadb_obj.dir/ma_sha1.c.gcn
./dbug/CMakeFiles/dbug.dir/dbug.c.gcno
./dbug/CMakeFiles/tests.dir/tests.c.gcno
./dbug/CMakeFiles/factorial.dir/factorial.c.gcno
./sql/CMakeFiles/sql.dir/my_json_writer.cc.gcno  ## cc files
./sql/CMakeFiles/sql.dir/sql_window.cc.gcno
./sql/CMakeFiles/sql.dir/item_jsonfunc.cc.gcno
 
 
/*result*/
$./mtr --gcov is_check_constraints
...
unknown line 'lcount:2229,0' after running 'gcov -i 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 184, <FH> line 697.
unknown line 'lcount:2232,0' after running 'gcov -i 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 184, <FH> line 698.
unknown line 'lcount:2235,0' after running 'gcov -i 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 184, <FH> line 699.
unknown line 'lcount:2236,0' after running 'gcov -i 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 184, <FH> line 700.
 
$ ./var/last_changes.dgcov  # obtained but empty

---------------------------------------------------------------------------------

/*******  EXAMPLE 2: gcc,g++ 6.5; gcov 6.5 *******/
# Compilation same as above
$ alias gcov="/usr/bin/gcov-6"
$ gcov --version
gcov (Ubuntu 6.5.0-2ubuntu1~18.04) 6.5.0 20181026
/*result*/
$./mtr --gcov is_check_constraints
# Same as above

---------------------------------------------------------------------------------

/*******  EXAMPLE 3-4: gcc,g++ 9.3; gcov 6.5/7.5 *******/
$ ./mtr --gcov is_check_constraints
 
==============================================================================
 
TEST                                      RESULT   TIME (ms) or COMMENT
--------------------------------------------------------------------------
 
worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 16000..16019
funcs_1.is_check_constraints 'innodb'    [ pass ]    396
--------------------------------------------------------------------------
The servers were restarted 0 times
Spent 0.396 of 6 seconds executing testcases
 
Completed: All 1 tests were successful.
 
Running dgcov
# here is counting the files and finishes
 
---------------------------------------------------------------------------------

Comment by Anel Husakovic [ 2021-06-14 ]

Working version is on 10.2 (bb-10.2-anel-MDEV-20787) and 10.6 (bb-10.6-anel-MDEV-20787) branches.
Example: From diff dgcov file is generated!
1. Create the patch:

$ git diff
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index b5622497a06..5fbc7bb5e4a 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -6588,7 +6588,7 @@ static int get_check_constraints_record(THD *thd, TABLE_LIST *tables,
       }
 #endif
       Virtual_column_info *check= tables->table->check_constraints[i];
-      table->field[0]->store(STRING_WITH_LEN("def"), system_charset_info);
+      table->field[0]->store(STRING_WITH_LEN("defition"), system_charset_info);
       table->field[3]->store(check->name.str, check->name.length,
                              system_charset_info);
       /* Make sure the string is empty between each print. */

2. Run the test with --gcov flag:

$ ./mtr --gcov is_check_constraints.test
Logging: ./mtr  --gcov is_check_constraints.test
vardir: /home/anel/mariadb/10.2-worktree-in-source/mysql-test/var
Checking leftover processes...
Removing old var directory...
Creating var directory '/home/anel/mariadb/10.2-worktree-in-source/mysql-test/var'...
Checking supported features...
MariaDB Version 10.2.39-MariaDB-debug
 - SSL connections supported
 - binaries are debug compiled
 - binaries built with wsrep patch
Collecting tests...
Installing system database...
 
==============================================================================
 
TEST                                      RESULT   TIME (ms) or COMMENT
--------------------------------------------------------------------------
 
worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 16000..16019
funcs_1.is_check_constraints 'innodb'    [ pass ]    317
--------------------------------------------------------------------------
The servers were restarted 0 times
Spent 0.317 of 6 seconds executing testcases
 
Completed: All 1 tests were successful.
 
Running dgcov

3. Validate results:

$ cat var/last_changes.dgcov
*********************
dgcov sql/sql_show.cc
*********************
@@ +6588,7 @@ static int get_check_constraints_record(THD *thd, TABLE_LIST *tables,
         : 6588:      }
         : 6589:#endif
         : 6590:      Virtual_column_info *check= tables->table->check_constraints[i];
      132: 6592:      table->field[0]->store(STRING_WITH_LEN("defition"), system_charset_info);
         : 6593:      table->field[3]->store(check->name.str, check->name.length,
         : 6594:                             system_charset_info);

Note for Serg:
we can still use:

IF (ENABLE_GCOV)
  MY_CHECK_AND_SET_COMPILER_FLAG("--coverage" DEBUG)

like in patch 8c34a242aa2d4e8

Comment by Anel Husakovic [ 2021-06-15 ]

Obtained different result with 10.6.
There is a problem when compiling with WITH_SSL=bundled what is the scope of other MDEV: MDEV-25914!

However result is not the same as in 10.2, but this is not the scope of this MDEV, probably new one or even result of MDEV-25914.
Result in 10.6 - var/last_changes.dgcov file is empty, but on stdout gcov cannot parse properly - what may be caused by MDEV-25914.

unknown line 'lcount:4141,0' after running 'gcov -i 'mysqltest.cc.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 184, <FH> line 1540.
unknown line 'lcount:4142,0' after running 'gcov -i 'mysqltest.cc.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 184, <FH> line 1541.
unknown line 'lcount:4143,0' after running 'gcov -i 'mysqltest.cc.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 184, <FH> line 1542.
unknown line 'lcount:4145,0' after running 'gcov -i 'mysqltest.cc.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 184, <FH> line 1543.
unknown line 'lcount:4148,0' after running 'gcov -i 'mysqltest.cc.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 184, <FH> line 1544.
unknown line 'lcount:4149,0' after running 'gcov -i 'mysqltest.cc.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 184, <FH> line 1545.
unknown line 'lcount:4151,0' after running 'gcov -i 'mysqltest.cc.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 184, <FH> line 1546.
unknown line 'lcount:4157,0' after running 'gcov -i 'mysqltest.cc.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 184, <FH> line 1547.
unknown line 'lcount:4160,0' after running 'gcov -i 'mysqltest.cc.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 184, <FH> line 1548.
unknown line 'lcount:4161,0' after running 'gcov -i 'mysqltest.cc.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 184, <FH> line 1549.
unknown line 'lcount:4162,0' after running 'gcov -i 'mysqltest.cc.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 184,

I don't have nothing to add to this MDEV.
serg can you please review the tests and the patch.
Thanks

Comment by Anel Husakovic [ 2021-06-15 ]

Pushed to 10.6 with 6e282e7efc0be5c should I backport to 10.2 ?
I guess it is ok to push.

Comment by Sergei Golubchik [ 2021-06-15 ]

Well, you didn't reply to my review https://lists.launchpad.net/maria-developers/msg12452.html

May be, all you needed to do was

--- a/mysql-test/dgcov.pl
+++ b/mysql-test/dgcov.pl
@@ -162,7 +162,7 @@ sub gcov_one_file {
   }
 
   # now, read the generated file
-  open FH, '<', "$_.gcov" or die "open(<$_.gcov): $!";
+  open FH, '<', "$`.gcov" or die "open(<$`.gcov): $!";
   my $fname;
   while (<FH>) {
     chomp;

Comment by Anel Husakovic [ 2021-06-15 ]

I had a draft prepared

but didn't send thought answering on jira would be enough.

Comment by Anel Husakovic [ 2021-06-15 ]

Tested your suggestion, doesn't work

unknown line 'lcount:2628,0' after running 'gcov -i 'random.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 178, <FH> line 416.
unknown line 'lcount:2632,0' after running 'gcov -i 'random.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 178, <FH> line 417.
unknown line 'lcount:2634,0' after running 'gcov -i 'random.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 178, <FH> line 418.
open(<my_sha512.cc.gcov): No such file or directory at ./dgcov.pl line 165.

Comment by Sergei Golubchik [ 2021-06-15 ]

Seems to be working just fine, doesn't it? my_sha512.cc.gcov is the correct file name that you want to open.

Comment by Anel Husakovic [ 2021-06-16 ]

Well yes it is correct name, but if we take for example this:

open(<mf_qsort2.c.gcov): No such file or directory at ./dgcov.pl line 168.

and inspect:

$ find .|grep mf_qsort2
./mysys/mf_qsort2.c
./mysys/CMakeFiles/mysys.dir/mf_qsort2.c.gcno
./mysys/CMakeFiles/mysys.dir/mf_qsort2.c.o.d
./mysys/CMakeFiles/mysys.dir/mf_qsort2.c.o
./mysys/CMakeFiles/mysys.dir/mf_qsort2.c.gcda

we see that in object file directory, there is gcno file created during compile time, gcda file, created when binary is run (meaning binary was used for the test), but it's missing .gcov file that should be produced from gcov -i <source-name>.gcda.
That means that the command gcov is not finished/or not executed yet.
Could it be some latency between system and open calls ?
I noted this behavior already when debugging and this was the reason for check in latest version of my patch e02ffc0ccaa4f5f84039f
Your patch is better then mine, thanks didn't know and used before special variable $` in perl.

Comment by Anel Husakovic [ 2021-06-16 ]

Regarding the unknown line (I'm not sure if this is related to MDEV-25915).
This is the content of gcov file:

[anel@localhost 10.2]$ more /home/anel/Desktop/10.2/mysys/CMakeFiles/mysys.dir/my_sleep.c.gcov
file:mysys/my_sleep.c
function:21,2,my_sleep
lcount:21,2
lcount:27,2
lcount:28,2
lcount:29,2
lcount:35,2

seems that realpath($'), where realpath is abs_path() and is translated to realpath(mysys/my_sleep.c) or storage/sequence/sequence.cc-> results in None.

I guess this should be a patch:

-      $fname=realpath($');
+      $fname=realpath($'=~s/(.+)\///r);

With this patch I can confirm that we don't get unknown line but still empty last_changes.dgcov .

Also

function:141,0,_ZN6ha_seq8positionEPKh
function:146,0,_ZN6ha_seq7rnd_posEPhS0_

With this patch:

-    $cmd= "gcov -i '$_' 2>/dev/null >/dev/null";
+    $cmd= "gcov -i -m '$_' 2>/dev/null >/dev/null";

it demangled function names (cpp).

Comment by Anel Husakovic [ 2021-06-16 ]

Have also analyzed function with write_coverage and printed hash that is created in scanning:

--- a/mysql-test/dgcov.pl
+++ b/mysql-test/dgcov.pl
@@ -73,6 +73,10 @@ find(\&gcov_one_file, $root);
 find(\&write_coverage, $root) if $opt_generate;
 exit 0 if $opt_only_gcov;
 
+  warn "print hash:\n";
+  warn "$_ $cov{$_}\n" for (keys %cov);

Result:

/home/anel/mariadb/10.2-in-source-builds/storage/innobase/CMakeFiles/innobase.dir/fts/fts0pars.cc HASH(0x55e5c46fed18)
/home/anel/mariadb/10.2-in-source-builds/storage/innobase/CMakeFiles/innobase.dir/pars/lexyy.cc HASH(0x55e5c46fe8f8)
/home/anel/mariadb/10.2-in-source-builds/storage/innobase/CMakeFiles/innobase.dir/fts/fts0blex.cc HASH(0x55e5c46f9628)
/home/anel/mariadb/10.2-in-source-builds/storage/innobase/CMakeFiles/innobase.dir/fts/fts0tlex.cc HASH(0x55e5c46d91e0)
/home/anel/mariadb/10.2-in-source-builds/storage/innobase/CMakeFiles/innobase.dir/pars/pars0grm.cc HASH(0x55e5c460dbd8)
/home/anel/mariadb/10.2-in-source-builds/sql/sql_yacc.cc HASH(0x55e5c473ac90)

But note that source files are in object directories but should be in source, what is a bug in real_path() in gcov_one_file ():

$ ls /home/anel/mariadb/10.2-in-source-builds/storage/innobase/CMakeFiles/innobase.dir/pars|grep lexyy
lexyy.cc.gcda
lexyy.cc.gcno
lexyy.cc.gcov
lexyy.cc.o
anel@anel:~$ cd mariadb/10.2-in-source-builds/
anel@anel:~/mariadb/10.2-in-source-builds$ find .|grep "lexyy\.cc"
./storage/innobase/pars/lexyy.cc

Comment by Anel Husakovic [ 2021-06-16 ]

serg can you please review 1f7e200ca0e3f43.
Some analysis Zulip

Comment by Sergei Golubchik [ 2021-06-21 ]

Ok, let's start from the basics. What gcc version should dgcov support?
For gcc 10.2.0, gcov -i produces json file and there is no option to generate the old intermediate format.
gcc 5, on the contrary, can do only the old intermediate format and knows nothing about json.

In what gcc version was json format introduced? in what gcc version was the old format dropped?

Comment by Anel Husakovic [ 2021-06-21 ]

Ok. Analysis done in [1]
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 [2].
Link:
[1] Zulip analysis
[2]Support GCOV intermediate format

Comment by Anel Husakovic [ 2021-07-07 ]

I have tested usage of gcov 9.4 intermediate format (json format).
First let's change gcc using update-alternatives:

$ update-alternatives --display gcc
gcc - manual mode
  link best version is /usr/bin/gcc-9
  link currently points to /usr/bin/gcc-6
  link gcc is /usr/bin/gcc
/usr/bin/gcc-6 - priority 6
/usr/bin/gcc-7 - priority 7
/usr/bin/gcc-9 - priority 9
$ alias gcc="/usr/bin/gcc-9"
$ gcc --version
gcc-9 (Ubuntu 9.4.0-1ubuntu1~18.04) 9.4.0

I had previously a simple MakeFile:

$ cat Makefile 
all: main.c
	gcc --coverage $^ -o $@
clean:
	rm -rf *.o *.gc* all

and with running make all -> gcc --coverage main.c -o all I ended with created .gcno file:

$ ls
all  main.c  main.gcno  Makefile

By executing executable following files all main.c main.gcda main.gcno Makefile are obtained.

Now I wanted to test gcov -i format in 9.4 which should be json intermediate format:

  -i, --json-format               Output JSON intermediate format into .gcov.json.gz file

Result (it can be invoked on gcda or source files):

$ gcov -i main.gcda 
main.gcno:version '605*', prefer 'A94*'
Segmentation fault (core dumped)

The reason was that because of using Makefile which is somehow related to old version of gcc (in my case it was 6.5 and don't know how to change this behavior between make and gcc, but there is a workaround).

Calling manually gcc works: $ gcc --coverage main.c -o main

$ gcov main.c 
main.gcda:cannot open data file, assuming not executed
File 'main.c'
Lines executed:0.00% of 3
Creating 'main.c.gcov
 
# so to call gcov we have to have gcda files first, but doesn't matter for now 
$ ls
main  main.c  main.c.gcov  main.gcno  Makefile
 
$ ./main
$ ls
main  main.c  main.c.gcov  main.gcda  main.gcno  Makefile
 
# data file with intermediate format
$ gcov -i main.gcda 
File 'main.c'
Lines executed:100.00% of 3
 
$ ls
main  main.c  main.c.gcov  main.gcda  main.gcda.gcov.json.gz  main.gcno  Makefile
 
# source file  with intermediate format
$ gcov -i main.c
File 'main.c'
Lines executed:100.00% of 3
 
$ ls
main  main.c  main.c.gcov  main.c.gcov.json.gz  main.gcda  main.gcda.gcov.json.gz  main.gcno  Makefile

Will create a new MDEV for this problem, as current MDEV is not related.

Comment by Sergei Golubchik [ 2021-07-15 ]

well, if the goal is to work on any gcc version where gcov has -i, then your patch will break on gcc before 7.x, right? On Ubuntu Xenial for example.

also, simply skipping files because my_sha512.cc.gcov didn't exist is incorrect, you lose data this way. If you'd run gcov without redirecting output to /dev/null you'd see that it creates my_sha.ic.gcov with the coverage information.

This is the fix that works for both gcc 4.x and gcc 7.x and does not lose any coverage information:

diff --git a/mysql-test/dgcov.pl b/mysql-test/dgcov.pl
--- a/mysql-test/dgcov.pl
+++ b/mysql-test/dgcov.pl
@@ -155,14 +155,16 @@ END
 sub gcov_one_file {
   return unless /\.gcda$/;
   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;
     logv "Running: $cmd";
     system($cmd)==0 or die "system($cmd): $? $!";
   }
 
   # now, read the generated file
+  for my $gcov_file (<$_*.gcov>) {
+  open FH, '<', "$gcov_file" or die "open(<$gcov_file): $!";
-  open FH, '<', "$_.gcov" or die "open(<$_.gcov): $!";
   my $fname;
   while (<FH>) {
     chomp;
@@ -183,6 +183,7 @@ END
     $cov{$fname}->{$1}+=$2;
   }
   close(FH);
+  }
 }
 
 sub write_coverage {

Comment by Anel Husakovic [ 2021-07-16 ]

Hi serg,

1. my patch should work on any version where -i is supported. I only had the first patch with wrong information about gcov and mislead about versions.However I wrote details about versions in Zulip and currently using gcc (Ubuntu 6.5.0-2ubuntu1~18.04) 6.5.0 20181026 for tests, tested with older on Centos -works, if you want I can proceed further with tests.

2. Example about my_sha512.cc.gcov where the file doesn't exist is unclear for me and is reason why I removed files not ending with gcov.
I tested with long file names -l options where I only got the different filenames separated with # and have pointed that in Zulip realpath too.
After gcov -i is invoked gcov file must be created! Documentation:

i
--intermediate-format
The output is a single .gcov file per .gcda file. No source code is required.

Header file <name>.hpp cannot have it's own gcov file. It is included in other file and gcda files are created on the exectuable. From gcda files are created gcov.
What is not clear for me, how gcda files for headers are created - I guess it has to do something with CMake and usage of add_convinience_library but I'm not sure.
And here I will again give the example what is happening:
If I remove skipping non-existing files in my patch:

 
return unless(-f "$`.gcov");
#return unless(-f "$`.gcov")

Invoke the test

==============================================================================
 
TEST RESULT TIME (ms) or COMMENT
 
worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 16000..16019
funcs_1.is_check_constraints 'innodb' [ pass ] 361
 
The servers were restarted 0 times
Spent 0.361 of 5 seconds executing testcases
 
Completed: All 1 tests were successful.
 
Running dgcov
open(<aestables.cpp.gcov): No such file or directory at ./dgcov.pl line 166.

Above gcov -i aestables.cpp.gcda is exectued, where aestables.cpp.gcda exists and gcov is not generated.
If you look the file it is just a namespace namespace TaoCrypt { ...} and is used with add_convinience_library.
I have done test of creating the static library with coverage and I'm ending without gcda files again only for exectuable files, but not files in the static library.

$ find .|grep aestables
./extra/yassl/taocrypt/src/aestables.cpp
./extra/yassl/taocrypt/CMakeFiles/taocrypt.dir/src/aestables.cpp.gcno
./extra/yassl/taocrypt/CMakeFiles/taocrypt.dir/src/aestables.cpp.o
./extra/yassl/taocrypt/CMakeFiles/taocrypt.dir/src/aestables.cpp.gcda

When applying your patch I ended with having gcov files with headers - but they are not needed for the coverage since gcda file is not creating it's own gcov - there is no aestables.cpp.gcov file that is parsed!

aestables.cpp.gcda##modes.hpp.gcov at ./dgcov.pl line 168.
aestables.cpp.gcda##runtime.hpp.gcov at ./dgcov.pl line 168.

But regardless, even if gcda files for header are created (for unknown reason - my culprit is CMake) gcov recognize them as not valid information file for creating gcov files and that's why they need to be skipped IMHO without lost of any information.
Regarding the -l, I think it is not related to above problem. I tested locally with header and don't end with gcda files for header even in case of -l option,but it is needed for your patch because of logic in for loop.

 
   -l
   --long-file-names
       Create long file names for included source files.  For example, if the header file x.h contains code, and was
       included in the file a.c, then running gcov on the file a.c will produce an output file called a.c##x.h.gcov
       instead of x.h.gcov.  This can be useful if x.h is included in multiple source files and you want to see the
       individual contributions.  If you use the -p option, both the including and included file names will be
       complete path names.

3. Applying only your patch doesn't work:

unknown line 'lcount:2165,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 672.
unknown line 'lcount:2175,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 673.
unknown line 'lcount:2177,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 674.
unknown line 'lcount:2179,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 675.
unknown line 'lcount:2180,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 676.
unknown line 'lcount:2181,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 677.
unknown line 'lcount:2183,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 678.
unknown line 'lcount:2188,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 679.
unknown line 'lcount:2191,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 680.
unknown line 'lcount:2192,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 681.
unknown line 'lcount:2194,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 682.
unknown line 'lcount:2200,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 683.
unknown line 'lcount:2204,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 684.
unknown line 'lcount:2206,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 685.
unknown line 'lcount:2207,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 686.
unknown line 'lcount:2209,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 687.
unknown line 'lcount:2210,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 688.
unknown line 'lcount:2211,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 689.
unknown line 'lcount:2212,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 690.
unknown line 'lcount:2213,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 691.
unknown line 'lcount:2218,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 692.
unknown line 'lcount:2221,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 693.
unknown line 'lcount:2222,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 694.
unknown line 'lcount:2225,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 695.
unknown line 'lcount:2228,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 696.
unknown line 'lcount:2229,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 697.
unknown line 'lcount:2232,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 698.
unknown line 'lcount:2235,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 699.
unknown line 'lcount:2236,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 180, <FH> line 700.

it is missing part from my patch $fname=$root.$';.

4. I don't get useful information without redirecting the output:

# running the test:
ma_alloc.c.gcno:version '605*', prefer 'A75*'
ma_alloc.c.gcda:version '605*', prefer version 'A75*'
open(<ma_alloc.c.gcda.gcov): No such file or directory at ./dgcov.pl line 168.
 
# again the file is not created:
$ find .|grep "my_alloc\.c"
./mysys/my_alloc.c
./mysys/CMakeFiles/mysys.dir/my_alloc.c.gcno
./mysys/CMakeFiles/mysys.dir/my_alloc.c.o
./mysys/CMakeFiles/mysys.dir/my_alloc.c.gcda

Conclusion

  • My conclusion after local testing is that we can safely skip files header files, we can add or remove -l and we will get the valid result.
    With both patches in my specific example result is the same.
    Even if you decide to go with your patch + addition, I'm ok with that, but I don't have strong proof why is needed (header usage explained above).

5. Oh one more thing. What I think is needed is this part:

   unless ($opt_skip_gcov) {
-    $cmd= "gcov -i '$_' 2>/dev/null >/dev/null";
+    $cmd= "gcov -i '$_' 2>/dev/null";

where information about files percentage is shown:

File 'mysys/my_basename.c'
Lines executed:0.00% of 10
Creating 'my_basename.c.gcov'
 
File 'mysys/my_rnd.c'
Lines executed:84.62% of 13
Creating 'my_rnd.c.gcov'
 
File 'mysys/mf_radix.c'
Lines executed:10.53% of 19
Creating 'mf_radix.c.gcov'
 
File 'sql-common/my_time.c'
Lines executed:15.03% of 572
Creating 'my_time.c.gcov'
 
File 'include/my_time.h'
Lines executed:45.45% of 11
Creating 'my_time.h.gcov'
 
File 'mysql-test/lib/My/SafeProcess/safe_process.cc'
Lines executed:24.62% of 130
Creating 'safe_process.cc.gcov'
 
File 'dbug/dbug.c'
Lines executed:34.67% of 649
Creating 'dbug.c.gcov'
 
*********************
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];
      132: 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);

without the suggested patch this is the result:

*********************
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];
      132: 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);

Comment by Sergei Golubchik [ 2021-07-16 ]

1. try your patch with gcc 5.4.0 for example on Ubuntu Xenial

2. depends on gcov version. 7.3.0 on Ubuntu Bionic say simply

  -i, --intermediate-format       Output .gcov file in intermediate text format

3. what gcc version is that? it worked on 5.4.0 and on 7.3.0

4. I don't understand what you're doing. I suggested to run gcov -i manually. Without 2>/dev/null >/dev/null

Comment by Anel Husakovic [ 2021-07-16 ]

1. I will test, ok.
2. Yes https://gcc.gnu.org/onlinedocs/gcc-7.3.0/gcc/Invoking-Gcov.html#Invoking-Gcov and what I said is based on that, don't understand what you meant ? -i --json is for 9.1+ and I have created MDEV-26102 for that.
3. I used 7.5 for my tests on Ubuntu Bionic
4. And that is exactly what I did, but on the test case ./mtr --gcov is_check_constraints when changing something in sql/sql_show.cc get_check_constraints_record.
what is your opinion for 5. ?

Comment by Sergei Golubchik [ 2021-07-16 ]

2. I mean that there's a fact of life that gcov 7.5 creates *.gcov files that do not always have the same base name as the *.gcda files. We can handle it. Or produce incorrect coverage. My patch handles it.

3. I tested on Ubuntu Bionic, and it worked.

5. you can do it in -v -v (very verbose) mode

Comment by Anel Husakovic [ 2021-07-17 ]

Hi Serg,
1. I have tested on Ubuntu Bionic with gcc/g++ 5.5

test gcc/g++ 5.5 with my patch

$ sudo apt-get update
$ sudo apt-get install gcc-5 g++-5 -y # this installs 5.5 versions
# the same gcc/g++ version is obtained if added from xenial
$ sudo touch /etc/apt/sources.list.d/xenial-anel.list && \
  echo "deb http://dk.archive.ubuntu.com/ubuntu/ xenial main" | sudo tee -a /etc/apt/sources.list.d/xenial-anel.list  &&\
  echo "deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe"|sudo tee -a /etc/apt/sources.list.d/xenial-anel.list  && sudo apt update
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 21
$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 21
$ sudo update-alternatives --display gcc
gcc - manual mode
  link best version is /usr/bin/gcc-5
  link currently points to /usr/bin/gcc-7
  link gcc is /usr/bin/gcc
/usr/bin/gcc-5 - priority 21
/usr/bin/gcc-6 - priority 6
/usr/bin/gcc-7 - priority 7
/usr/bin/gcc-9 - priority 9
 
$ sudo update-alternatives --display g++
g++ - manual mode
  link best version is /usr/bin/g++-5
  link currently points to /usr/bin/g++-7
  link g++ is /usr/bin/g++
/usr/bin/g++-5 - priority 21
/usr/bin/g++-6 - priority 6
/usr/bin/g++-7 - priority 7
/usr/bin/g++-9 - priority 9
$ sudo update-alternatives --config gcc
There are 4 choices for the alternative gcc (providing /usr/bin/gcc).
 
  Selection    Path            Priority   Status
------------------------------------------------------------
  0            /usr/bin/gcc-5   21        auto mode
  1            /usr/bin/gcc-5   21        manual mode
  2            /usr/bin/gcc-6   6         manual mode
* 3            /usr/bin/gcc-7   7         manual mode
  4            /usr/bin/gcc-9   9         manual mode
 
Press <enter> to keep the current choice[*], or type selection number: 1
$ gcc --version && g++ --version
gcc (Ubuntu 5.5.0-12ubuntu1) 5.5.0 20171010
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
g++ (Ubuntu 5.5.0-12ubuntu1) 5.5.0 20171010
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
$ git clean -dffx && cmake . -DCMAKE_BUILD_TYPE=Debug -DCONC_WITH_{UNITTEST,SSL}=OFF -DWITH_EMBEDDED_SERVER=OFF -DWITH_UNIT_TESTS=OFF -DPLUGIN_{ARCHIVE,TOKUDB,MROONGA,OQGRAPH,ROCKSDB,CONNECT,PERFSCHEMA,SPIDER,SPHINX}=NO -DWITH_SAFEMALLOC=OFF -DWITH_SSL=bundled -DENABLE_GCOV=ON -DCMAKE_{C_COMPILER=gcc,CXX_COMPILER=g++}-5
$ cmake --build .

If I check the result for my patch - it works:

result

==============================================================================
 
TEST                                      RESULT   TIME (ms) or COMMENT
--------------------------------------------------------------------------
 
worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 16000..16019
funcs_1.is_check_constraints 'innodb'    [ pass ]    340
--------------------------------------------------------------------------
The servers were restarted 0 times
Spent 0.340 of 5 seconds executing testcases
 
Completed: All 1 tests were successful.
 
Running 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];
      132: 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);

2. I analyzed in which situation names should be different and have showed that on your patch -> "aestable" example ^^^. However I couldn't locally reproduce to have headers with "gcov" extension, although documentation says that. By default it must have <source-name>.gcov and skipping everything else I don't see harmful.

3. Sorry I don't get working example based on your last patch, I don't know what I'm doing wrong or where we diverge.
I have tested on ver 6.5 and 7.5 Ubuntu Bionic (by changing CMAKE_

{C_COMPILER=gcc,CXX_COMPILER=g++}

-7) resulting in :

configuration

 
$ cmake . -DCMAKE_BUILD_TYPE=Debug -DCONC_WITH_{UNITTEST,SSL}=OFF -DWITH_EMBEDDED_SERVER=OFF -DWITH_UNIT_TESTS=OFF -DPLUGIN_{ARCHIVE,TOKUDB,MROONGA,OQGRAPH,ROCKSDB,CONNECT,PERFSCHEMA,SPIDER,SPHINX}=NO -DWITH_SAFEMALLOC=OFF -DWITH_SSL=bundled  -DENABLE_GCOV=ON -DCMAKE_\{C_COMPILER=gcc,CXX_COMPILER=g++\}-7 
$ cmake --build .
 
 
$ cmake . -LAH|grep -E "CMAKE_C_COMPILER|_CXX_COMPILER|GCOV"
CMAKE_CXX_COMPILER:STRING=/usr/bin/g++-7
CMAKE_CXX_COMPILER_AR:FILEPATH=/usr/bin/gcc-ar-7
CMAKE_CXX_COMPILER_RANLIB:FILEPATH=/usr/bin/gcc-ranlib-7
CMAKE_C_COMPILER:STRING=/usr/bin/gcc-7
CMAKE_C_COMPILER_AR:FILEPATH=/usr/bin/gcc-ar-7
CMAKE_C_COMPILER_RANLIB:FILEPATH=/usr/bin/gcc-ranlib-7
ENABLE_GCOV:BOOL=ON

Always I get the same result (see below).
I applied your patch on top of my patch (where I have added comments) + change for testing the mtr test:

patch

$ git diff dgcov.pl ../sql
diff --git a/mysql-test/dgcov.pl b/mysql-test/dgcov.pl
index 585586f9506..0bc1635a989 100755
--- a/mysql-test/dgcov.pl
+++ b/mysql-test/dgcov.pl
@@ -155,15 +155,17 @@ END
 sub gcov_one_file {
   return unless /\.gcda$/;
   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;
     logv "Running: $cmd";
     system($cmd)==0 or die "system($cmd): $? $!";
   }
 
   # now, read the generated file
-  return unless(-f "$`.gcov");
-  open FH, '<', "$`.gcov" or die "open(<$`.gcov): $!";
+  #return unless(-f "$`.gcov");
+  #open FH, '<', "$`.gcov" or die "open(<$`.gcov): $!";
+  for my $gcov_file (<$_*.gcov>) {
+  open FH, '<', "$gcov_file" or die "open(<$gcov_file): $!";
   my $fname;
   while (<FH>) {
     chomp;
@@ -171,7 +173,8 @@ sub gcov_one_file {
       next;
     }
     if (/^file:/) {
-      $fname=$root.$';
+      #$fname=$root.$';
+      $fname=realpath($');
       next;
     }
     next if /^lcount:\d+,-\d+/; # whatever that means
@@ -182,6 +185,7 @@ sub gcov_one_file {
     $cov{$fname}->{$1}+=$2;
   }
   close(FH);
+  }
 }
 
 sub write_coverage {
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 721bb053343..39f0a12132c 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -6601,7 +6601,7 @@ static int get_check_constraints_record(THD *thd, TABLE_LIST *tables,
       }
 #endif
       Virtual_column_info *check= tables->table->check_constraints[i];
-      table->field[0]->store(STRING_WITH_LEN("def"), system_charset_info);
+      table->field[0]->store(STRING_WITH_LEN("definition"), system_charset_info);
       table->field[3]->store(check->name.str, check->name.length,
                              system_charset_info);
       /* Make sure the string is empty between each print. */

This is the result:

result

$ ./mtr --gcov is_check_constraints
...
unknown line 'lcount:2218,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 182, <FH> line 692.
unknown line 'lcount:2221,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 182, <FH> line 693.
unknown line 'lcount:2222,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 182, <FH> line 694.
unknown line 'lcount:2225,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 182, <FH> line 695.
unknown line 'lcount:2228,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 182, <FH> line 696.
unknown line 'lcount:2229,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 182, <FH> line 697.
unknown line 'lcount:2232,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 182, <FH> line 698.
unknown line 'lcount:2235,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 182, <FH> line 699.
unknown line 'lcount:2236,0' after running 'gcov -il 'dbug.c.gcda' 2>/dev/null >/dev/null' at ./dgcov.pl line 182, <FH> line 700.
 
$ cat var/last_changes.dgcov  # empty

Tested with versions:

gcc-g++-gcov version 6

$ gcc --version && g++ --version && gcov --version
gcc (Ubuntu 6.5.0-2ubuntu1~18.04) 6.5.0 20181026
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
g++ (Ubuntu 6.5.0-2ubuntu1~18.04) 6.5.0 20181026
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
gcov (Ubuntu 6.5.0-2ubuntu1~18.04) 6.5.0 20181026
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.

Than changed version to 7.5 via update-alternatives

version 7.5 test

$ sudo update-alternatives --config gcc && sudo update-alternatives --config g++ && alias gcov="/usr/bin/gcov-7"
 
$ gcc --version && g++ --version && gcov --version
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
gcov (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.
$ cmake --build .

However if I change the line to my patch

change of root

     if (/^file:/) {
       $fname=$root.$'; # part of my patch
+      #$fname=realpath($');

Then result is:

result-expected

$ 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];
      132: 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);

5. Tested with --verbose --verbose ending with missing information about the file usage in var/last_changes.dgcov, so still I'm thinking that removing stdout redirection from gcov -i would be good.

Generated at Thu Feb 08 09:02:10 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.