Bug 1552042 - gcc creates gcno files not readable by lcov
Summary: gcc creates gcno files not readable by lcov
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: lcov
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Daniel Berrangé
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 1555038 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-03-06 11:59 UTC by Sumit Bose
Modified: 2018-11-16 21:41 UTC (History)
16 users (show)

Fixed In Version: lcov-1.13-3.fc29 lcov-1.13-4.fc28
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-06-02 20:42:40 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
GNU Compiler Collection 84735 0 None None None 2019-04-03 08:49:26 UTC

Description Sumit Bose 2018-03-06 11:59:08 UTC
Description of problem:
If a *.c file only contains some global constant the gcno file produced by the --coverage option is not readable by lcov

Version-Release number of selected component (if applicable):
gcc-8.0.1-0.16.fc29.x86_64

How reproducible:

[build@localhost tmp]$ cat t.c 
const int a = 5;
[build@localhost tmp]$ gcc -Wall -Wextra -Werror  -c ./t.c --coverage
[build@localhost tmp]$ lcov --capture --initial --directory . 
Capturing coverage data from .
Found gcov version: 8.0.1
Scanning . for .gcno files ...
Found 2 graph files in .
Processing t.gcno
geninfo: ERROR: /tmp/t.gcno: reached unexpected end of file


The same works as expected with gcc-7.3.1-2.fc27.x86_64 on Fedora 27:

[sbose@p50 y]$ cat t.c 
const int a = 5;
[sbose@p50 y]$ gcc -Wall -Wextra -Werror --coverage -c t.c 
[sbose@p50 y]$ lcov --capture --initial --directory .
Capturing coverage data from .
Found gcov version: 7.3.1
Scanning . for .gcno files ...
Found 1 graph files in .
Processing t.gcno
TN:
Finished .info-file creation

Comment 1 Jakub Jelinek 2018-03-06 12:03:12 UTC
If it works with gcov, then it is a bug or missing support on the lcov side.

Comment 2 Daniel Berrangé 2018-03-06 13:27:44 UTC
Presumably this is some new data format introduced in the files by latest toolchain. There's no sign of any recent fixes upstream lcov git, so probably no immediate easy solution to it.

Comment 3 Daniel Berrangé 2018-03-06 13:49:11 UTC
Reported upstream at https://github.com/linux-test-project/lcov/issues/38

Comment 4 Sumit Bose 2018-03-06 14:25:08 UTC
Jakub, I guess the change is caused by https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=254627

...
diff --git a/gcc/coverage.c b/gcc/coverage.c
index f57897b8314..ea05d94f441 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -1269,6 +1269,9 @@ coverage_init (const char *filename)
          gcov_write_unsigned (GCOV_NOTE_MAGIC);
          gcov_write_unsigned (GCOV_VERSION);
          gcov_write_unsigned (bbg_file_stamp);
+
+         /* Do not support has_unexecuted_blocks for Ada.  */
+         gcov_write_unsigned (strcmp (lang_hooks.name, "GNU Ada") != 0);
        }
     }
...


With the example above on rawhide I get a gcno file with 16 bytes:

[build@localhost tmp]$ od -c < t.gcno 
0000000   o   n   c   g   R   0   8   A   Q 256 235 373 001  \0  \0  \0
0000020

while on F27 there are only the first 12 bytes (magic, version and stamp)

So lcov should expect another int32 in the header?

Maybe gcc/gcov-io.h can be update to document this?

Comment 5 Jakub Jelinek 2018-03-06 14:44:07 UTC
This is just one of the several changes in the format.  I've filed http://gcc.gnu.org/PR84735 to let Martin Liska describe what he has changed, but he recommends not to use these files directly.

Comment 6 Sumit Bose 2018-03-06 14:52:07 UTC
(In reply to Jakub Jelinek from comment #5)
> This is just one of the several changes in the format.  I've filed
> http://gcc.gnu.org/PR84735 to let Martin Liska describe what he has changed,
> but he recommends not to use these files directly.

Thank you.

Comment 7 Sumit Bose 2018-03-07 13:31:46 UTC
Daniel, https://github.com/linux-test-project/lcov/commit/a5dd9529f9232b8d901a4d6eb9ae54cae179e5b3 was just commited. Can you add it to the rawhide version of lcov?

Comment 8 Fedora Update System 2018-03-14 10:06:48 UTC
lcov-1.13-3.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2018-7c8545beeb

Comment 9 Daniel Berrangé 2018-03-14 11:09:16 UTC
*** Bug 1555038 has been marked as a duplicate of this bug. ***

Comment 10 Fedora Update System 2018-03-14 18:05:57 UTC
lcov-1.13-3.fc28 has been pushed to the Fedora 28 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-7c8545beeb

Comment 11 Fedora Update System 2018-04-30 12:15:22 UTC
lcov-1.13-4.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2018-504ce49143

Comment 12 Fedora Update System 2018-04-30 19:55:19 UTC
lcov-1.13-4.fc28 has been pushed to the Fedora 28 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-504ce49143

Comment 13 Fedora Update System 2018-06-02 20:42:40 UTC
lcov-1.13-4.fc28 has been pushed to the Fedora 28 stable repository. If problems still persist, please make note of it in this bug report.

Comment 14 Nikos Mavrogiannopoulos 2018-11-16 21:41:18 UTC
Hi,
 Is that fully addressed in Fedora? I noticed a large drop in gnutls' coverage report few months ago as reported by lcov (from 77% to 74.5, today it is being reported as low as 69% on f29). We could move to an earlier fedora (e.g., 27) to get a more accurate view, however that would mean reducing coverage as we lose new functionality like interop tests with openssl1.1.1, and software tpm emulator.


https://gitlab.com/gnutls/gnutls/issues/550
https://gnutls.gitlab.io/coverage/master/


Note You need to log in before you can comment on or make changes to this bug.