swtv-kaist / cs458-spring24

7 stars 0 forks source link

HW3 - GCOV doesn't show function branch coverage #6

Closed leporia closed 6 months ago

leporia commented 6 months ago

Using GCOV I cannot obtain the example output showed in the assignment PDF. I only see branch coverage for the overall file and only see line coverage for each function. For example this is what I obtain by running gcov -b -f

Function 'main'
Lines executed:100.00% of 36

Function 'alt_sep_test'
Lines executed:75.00% of 16

Function 'Own_Above_Threat'
Lines executed:0.00% of 2

Function 'Own_Below_Threat'
Lines executed:100.00% of 2

Function 'Non_Crossing_Biased_Descend'
Lines executed:83.33% of 6

Function 'Non_Crossing_Biased_Climb'
Lines executed:83.33% of 6

Function 'Inhibit_Biased_Climb'
Lines executed:100.00% of 2

Function 'ALIM'
Lines executed:100.00% of 2

Function 'initialize'
Lines executed:100.00% of 6

File 'tcas-mod-mcdc.c'
Lines executed:89.74% of 78
Branches executed:72.73% of 66
Taken at least once:40.91% of 66
Calls executed:84.21% of 38
Creating 'tcas-mod-mcdc.c.gcov'

Lines executed:89.74% of 78

But on the assignment pdf it shows an output in the following format

Lines executed:22.22% of 36
Branches executed:100.00% of 2
Taken at least once:50.00% of 2
Calls executed:27.27% of 22

Function 'alt_sep_test'
Lines executed:0.00% of 16
Branches executed:0.00% of 34
Taken at least once:0.00% of 34
Calls executed:0.00% of 4

Function 'Own_Above_Threat'
Lines executed:0.00% of 2
No branches
No calls

Function 'Inhibit_Biased_Climb'
Lines executed:0.00% of 2
Branches executed:0.00% of 2
Taken at least once:0.00% of 2
No calls

Function 'ALIM'
Lines executed:0.00% of 2
No branches
No calls

Function 'initialize'
Lines executed:0.00% of 6
No branches
No calls

File 'tcas-mod.c'
Lines executed:10.26% of 78
Branches executed:3.03% of 66
Taken at least once:1.52% of 66
Calls executed:15.79% of 38
Creating 'tcas-mod.c.gcov’

This is both on my local machine and on the given remote machine. On my machine I'm running gcov (GCC) 13.2.1 20240316 (Red Hat 13.2.1-7) On the remote gcov (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

I'm up-to-date on my machine, I cannot update the GCC suite any further. Which version of GCOV was used for the example? Is it okay if my output doesn't show branch coverage? Maybe I'm missing some additional arguments to GCOV?

3-24 commented 6 months ago

Sorry, it seems latest GNU removed function level branch coverage feature.

Please use llvm-cov gcov instead, which is a part of LLVM infrastructure installed in the provided server. For instance, enter the following command to check the function level branch coverage summary.

llvm-cov gcov -b -f bin
leporia commented 6 months ago

Thanks, but now it seems that I have another problem as it says "No branches" for all functions. Actually I don't really need this feature as using lcov and genhtml give similar data. I was just wondering if it is required to report a similar output or is enough to describe and motivate. I'm talking specifically for Part IV subpoint c. For the other points it shouldn't be needed if I'm understanding correctly.

Function 'initialize'
Lines executed:0.00% of 6
No branches
No calls

Function 'ALIM'
Lines executed:0.00% of 2
No branches
No calls

Function 'Inhibit_Biased_Climb'
Lines executed:0.00% of 2
No branches
No calls

Function 'Non_Crossing_Biased_Climb'
Lines executed:0.00% of 14
No branches
No calls

Function 'Non_Crossing_Biased_Descend'
Lines executed:0.00% of 14
No branches
No calls

Function 'Own_Below_Threat'
Lines executed:0.00% of 2
No branches
No calls

Function 'Own_Above_Threat'
Lines executed:0.00% of 2
No branches
No calls

Function 'alt_sep_test'
Lines executed:0.00% of 24
No branches
No calls

Function 'main'
Lines executed:21.05% of 38
No branches
No calls

File 'tcas-mod-mcdc.c'
Lines executed:7.69% of 104
Branches executed:4.17% of 48
Taken at least once:2.08% of 48
No calls
Creating 'tcas-mod-mcdc.c.gcov'
swtv-kaist commented 6 months ago

Thank you for the timely question.

  1. I found that TA upgraded haster machines to use ubuntu 22 and a new version of gcc/gcov was installed, which shows only line coverage information on each function.

  2. Thus, you don't have to report branch coverage information per function in your HW.