Re: Question about the coverage statistics of Gcov

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thank your reply! 

I have modified my code.As shown below:
  1         -:    0:Source:test_o.c
  2         -:    0:Graph:test_o.gcno
  3         -:    0:Data:test_o.gcda
  4         -:    0:Runs:1
  5         -:    1:#include <stdio.h>
  6         -:    2:
  7         -:    3:
  8         1:    4:static int fun()
  9         -:    5:{
 10         1:    6:     float a = 0x1.9p+1;
 11         1:    7:     int b = 0xA20B95AEL;
 12         1:    8:     for(int i=0;i<2;i++)
 13         -:    9:     {
 14         1:   10:         int c = 4;
 15         1:   11:         return 4;
 16         -:   12:     }
 17     #####:   13:     return 1;
 18         -:   14:}
 19         1:   15:int main()
 20         -:   16:{
 21         1:   17:    int result=fun();
 22         1:   18:    printf("%d \n",result);
 23         1:   19:    return 0;
 24         -:   20:}
 25         -:   21:

As you said, the 8th line has some unexecuted parts, i.e., “ i++ ” so why is not the execution time of the 8th line 1*?

> 在 2021年4月3日,上午7:15,Jim Wilson <jimw@xxxxxxxxxx> 写道:
> 
> On Fri, Apr 2, 2021 at 1:50 AM heng zhang via Gcc-help <gcc-help@xxxxxxxxxxx <mailto:gcc-help@xxxxxxxxxxx>> wrote:
> Why is the executed time of the 8th line performed 1* and what does the symbol ‘*' means?  According to the explanation of the official web,  executed basic blocks having a statement with zero execution_count end with ‘*’ character. For this case, there is not any unexecuted statement in for loop. When the 11th line is pruned, the executed time of the 8th line is only 1. so is it a bug?
> 
> The line 
>  12        1*:    8:     for(int i=0;i<2;i++)
> is effectively more than one piece of code.  One of those pieces of code wasn't executed.  If you put a newline after every ; and rerun gcov, the results may make more sense.  But exactly attributing counts for some complex statements like a for loop header is tricky, so it may always be a little misleading.  Better is to just use the counts of the statements inside the block and not worry about the for loop header.
> 
> Jim
> 





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux