-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent/wrong line coverage #185
Comments
lcov is merely presenting coverage data generated by gcov. Another way that this can happen is if your source code version is not aligned with your build - so the instrumented executable refers to different line numbers than correspond to your current source code. The other thing you probably want to do is to try the current lcov TOT, as there have been some extensive changes and quite a few fixes since 1.16. Hope this helps |
The other thing to try is to remove the "-O0" flag and see if that fixes your coverage report. |
|
Bummer. Could also try with LLVM and see if that gives a different result. Different gcc version might also be interesting. |
|
the gcov man page says:
.. which appears to be what we see here. Could you run the same thing with "gcov -i" (json format output) - and show me what that looks like as well? Thanks |
Sure, I'll upload the whole file though, since I can see that relevant data might be scattered. |
Could you take a quick look at some of the other lines which are marked 'hit' but which have unexecuted blocks. I replaced '{' with '\n{' in the JSON file, then ran
to find a bunch of lines in your file - say, lline 995, 1001, 1331, 1372, ... and so on (23 lines in total) |
It seems that for complex statements it's probably correct (there's a part of the condition on a given line that's not executed, but it's hard to parse this .json data manually), for example:
There are however also instances that are a bit puzzling to me:
I'm not sure how this intersects with other sources of data, so I'll leave the interpretation up to you. |
Sorry for all the requests...but your testcase seems to easily generate some conditions that my simple cases do not. Could you run gcov again, this time adding flags "-c -a -i" (turn on branch data). Ultimately, once we have resolved this issue, it will be interesting to look at a differential coverage report comparing 'before' and 'after' - to see what the differences are. This could help us figure out if there are more issues we have to fix. Thanks |
Each of these calls resulted in the same file (same checksum and size). Commands ran:
Let me know if I should run them in any other way. |
Yeah...can you try yet again, with "-b -x -i". |
As an update in the meantime - running this with clang yielded better results:
Local patch added:
|
|
Cool.
Then look for lines, branches, function in categories other than "UBC" and "CBC". |
The simple hack triggers on lines 1857 and 1001 - but it looks like line 1001 is probably not actually hit in your data either. |
Yep. Another faulty result, just not one that I noticed. |
SHA 7a538ee contains the above hack. |
Unfortunately, running any genhtml diff as requested above results in an error. Command:
result: |
Sorry about that. Reversed the parameter order by mistake. Please update to sha e5c10ef and try again. |
Results look better, lines 1001 and 1857 are now consistent with real behaviour. The diff yields some strange results though, for example coverage in the line range around 1977 is the same between gcov (with the new option on) vs llvm_cov, but the diff shows otherwise: Side-note: the |
Getting there...but not arrived yet, it seems. For one or two of the lines that are still categorized incorrectly by the new filtering option (claimed hit when not actually hit, or claimed not hit when actually hit): could you send me the gcov output data - both gcc and llvm if you have it. We may not be able to get to perfection...but we can try. Correctness is important, if you are using this tool to drive verification. |
Sorry..misread your comment/question regarding line 1977. Why you might want that is for ongoing development:
The paper mentioned in the project README has a fairly detailed description about the topic of coverage criteria and automation. The other thing I noticed in your result is that gcc and llvm are showing a different number of branches on line 787 (6 and 4, respectively, I think). This is very likely due to differences in how they generated exception handlers - and is yet another issue that makes branch coverage a bit painful to use :-( |
It looks to me that the initial issue is fixed now, isn't it? |
Hi @AndrzejKurek (or @GitMensch ..or anyone) - I'm curious if the LLVM profile data shows similar artifacts or not. Thanks |
Hi @henry2cox Thanks for the update. In Mbed TLS, we're still interested in accuracy improvements, but I'm afraid we don't really have time to dig into this at the moment. Andrzej is no longer working on Mbed TLS. You should be able to compare measurements on Mbed TLS easily: just grab a release and run |
Hi Gilles - |
I'm in a similar boar as Gilles, while I'd find the result interesting I won't do that myself any time soon. CODE_COVERAGE_CPPFLAGS="-DNDEBUG"
CODE_COVERAGE_CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
CODE_COVERAGE_CXXFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
CODE_COVERAGE_LIBS="-lgcov" |
Hi there, I'm investigating line coverage for a new feature that I'm introducing to Mbed TLS, and I'm seeing inconsistencies when it comes to line coverage (branch information seems fine):
line 1857 is hit, even though nothing executed it.
Reproduction steps:
Starting from here:
Check
library/x509_crt.c
coverage, line 1856 & 1857. The insides of the condition should not be hit.I reduced the number of tests run to one that highlights the problem.
If you're not able to run this test or you'd like me to produce a possibly minimal test case - let me know, I'll try harder :)
Tool versions:
lcov 1.14 and 1.16 tested;
gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
The text was updated successfully, but these errors were encountered: