On 1/5/25 18:23, Jan Hubicka wrote:
The gcov function summaries only output the covered lines, not the branches and calls. Since the function summaries is an opt-in it probably makes sense to also include branch coverage, calls, and condition coverage.$ gcc --coverage -fpath-coverage hello.c -o hello $ ./hello Before: $ gcov -f hello Function 'main' Lines executed:100.00% of 4 Function 'fn' Lines executed:100.00% of 7 File 'hello.c' Lines executed:100.00% of 11 Creating 'hello.c.gcov' After: $ gcov -f hello Function 'main' Lines executed:100.00% of 3 No branches Calls executed:100.00% of 1 Function 'fn' Lines executed:100.00% of 7 Branches executed:100.00% of 4 Taken at least once:50.00% of 4Doesn't we care if all possible outcomes of the branch was taken? I.e. if the branch is always taken, will I see 100% here?
As far as I understand it, if the *same* branch is always taken (as in this case) it will be 50%, not 100%.
Also what about switch statements?
Switch statements are just branches as far as I'm aware, so they would be counted individually towards "taken at least once".
gcc/ChangeLog: * gcov.cc (generate_results): Count branches, conditions. (function_summary): Output branch, calls, condition count.Patch looks OK, but perhaps the report above can be clarified a bit...
Thanks. For the patch I re-used the same strings used for files. It is a bit confusing, I agree, but should then probably also be revised for the file level report. It also re-uses the same message structure for conditions, e.g.:
Lines executed:0.00% of 10 Branches executed:0.00% of 6 Taken at least once:0.00% of 6 No calls Condition outcomes covered:0.00% of 6
Also I apologize for taking so long to get to the patchset. I will review it now and will definitely try to do better next time. Honza
