Closed changyuang closed 3 weeks ago
The .gcov file can be generated successfully using gcov, but it fails using lcov
when i use gcov,The following information will appear, but the .gcov file will eventually be generated
aosp/metrics_reporter_android.gcno:no lines for '_ZN7android6fs_mgr15MetadataBuilderD2Ev'
aosp/metrics_reporter_android.gcno:no lines for '_ZN7android6fs_mgr14PartitionGroupD2Ev'
aosp/metrics_reporter_android.gcno:no lines for '_ZN7android6fs_mgr9PartitionD2Ev'
aosp/metrics_reporter_android.gcno:no lines for '_ZN22chromeos_update_engine24MetricsReporterInterfaceC2Ev'
aosp/metrics_reporter_android.gcno:no lines for '_ZN7android6fs_mgr10LpMetadataD2Ev'
Could this be the reason why lcov failed?
Which version of lcov are you using? Similarly, which compiler and compiler version?
A quick check of the code indicates that lcov --capture ...
should emit gcov's stderr gcov returned an error code, and that lcov --capture -v -v ...
will print stdout as well.
Do you have a testcase which exhibits the issue?
lcov version is 1.10,and i use file command to check gcno and gcda file,the version displayed is as follows
main.gcno: GCC gcno coverage (-ftest-coverage), version 4.8
main.gcno: GCC gcno coverage (-ftest-coverage), version 4.8
aosp/metrics_reporter_android.gcda: GCC gcda coverage (-fprofile-arcs), version 4.8
aosp/metrics_reporter_android.gcno: GCC gcno coverage (-ftest-coverage), version 4.8
when i delete metrics_reporter_android.gcda and metrics_reporter_android.gcno file, lcov command succeed. I want to know why some files will fail and some will succeed.
lcov/1.10 pre-dates the switch to github - so is prior to 2015. You need to update to a newer version where your issue may already be fixed.
i have changed the lcov version to 1.16,but it also failed as follows.How should i proceed?
Capturing coverage data from .
Found gcov version: 4.8.5
Scanning . for .gcda files ...
Found 2 data files in .
Processing aosp/metrics_reporter_android.gcda
geninfo: ERROR: GCOV failed for /media/work/update_engine/aosp/metrics_reporter_android.gcda!
From your error message: it appears that gcov is not happy - say, is returning an error code when processing 'metrics_reporter_android.gcda'. Old lcov versions saw that as a fatal error, and stopped. Newer versions can be configured to ignore the issue and keep going.
However: the gcov data is very likely still wrong/not captured correctly by gcov - and hence not processed by lcov even if you update to the latest release. To address this: you very likely need a newer gcc which doesn't have the bug. As with your lcov/1.10 problem: gcc/4.8.X is very old at this point. However: you may or may not be able to update your toolchain - or, at least I can think of a lot of really good reasons why you would not be able to update your compiler and toolchain.
I think you have at least 3 alternatives:
update tool versions. Current LCOV release is 2.1 (two years and many, many code changes newer than 1.16.) If you can update to that: then you can probably bypass the gcov issue and generate a coverage report (but with incomplete data - see above). Current GCC is 13.X, and current LLVM is 18.X. It is quite likely that your gcov bug was fixed in gcc/9.X (or later). There were a lot of changes in gcc/9.
Exclude this file - and all the other files which see similar issues from the set that lcov --capture
sees.
In old lcov versions, the only way I know to do that is to run a script to delete or rename the offending files.
Of course - if you remove or ignore the files, then your coverage report will contain no data from those compilation units.
Copy your data (the .gcda and .gcno files) to a different machine - say, a linux box where you can install lcov/2.1 - and then run your capture command there. You may also need to run genhtml on that machine as well (...so you may need your source code as well as the coverage data files), as the data files generated by lcov are slightly different between 2.0/2.1 and older lcov releases. (Backward compatible - but not forward compatible.)
Thanks for your answer! I'll try out those methods. I have another question to ask: where can I find the corresponding versions between gcc, llvm, and gcno?
If I understand the question:
gcov
is part of the gcc toolchain - and a compatible gcov version will be in the same place as the corresponding gcc
/g++
executable.
Generally: gcov will complain if it finds a gcda/gcno file with the wrong magic number.
similarly, llvm-cov
is part of the llvm toochain - and will be found where your clang
, llvm-objdump
, etc. executables are found. Again: you should use compatible toolchain components.
It is also true that the gcov data that llvm produces is compatible with gcov/4.2 (or was nearly compatible).
Despite that compatibility, I think that it is a really bad idea to use 'gcov' from some gcc install with the data generated by llvm. It might work - or might appear to work - but you are playing with fire.
We care very deeply about code quality as well as correctness of the reports we are relying on - and so would not take that risk.
No updates in a couple of months. I presume that this means that the issue is resolved (or you no longer care about it). In a few days, I will go ahead and close this issue - unless there is something more that needs to be done.
Closing this issue now. If there is still a problem, please feel free to reopen this issue or file a new one. Please describe the problem in detail and provide a testcase which illustrates the issue, if possible.
when i use lcov in Android,such as following command:
An error occurred, the error message is as follows:
I want to know the detailed error information and what should I do?