PGPROF : Coverage problem

When using pgprof with ‘-c’ option all the subroutines of the profiled program appear 100% covered, which is impossible in my case.

The program was compiled with pgf77 (v4.1.2) using -Mprof=func,lines option.

I also wrote a small C program containing the following instruction
if ( 1 == 0 ) printf (“test”);
Obviously such program cannot be 100% covered, although pgrpof displays full coverage of it.

Anyone can find an explanation of this behaviour? Thanx a lot.

Hi blagaa,

At low opts, the “if (1==0)” statement is evaluated so would show-up in the profiler. Changing the line to:

if (1==0) {
      printf("test");
}

would show that the “if” statement is executed but not the printf. Note that “-O2”, dead code elimiation would remove this line altogether.

Example:

Profiled: a.out on Thu Jan 12 09:12:18 PST 2006 for 0.00015 seconds

Line hello.c@main                  Process Time            

 3   int main () {                                         
 4     if (1 == 0) printf("test"); 0 (4)    0.000031 = 21% 
 5     if (1 == 0) {               0 (5)    0.000021 = 14% 
 6       printf("test");                                   
 7     }                                                   
 8     return 0;                   0 (8)    0.000037 = 25% 
 9   }                             0 (9)    0.000028 = 18% 
10

Hope this clears things up,
Mat

hank you very much for your help.

Unfortunately I tested your helo.c program and I still have the same 100% coverage problem.

pgcc -O0 -Mprof=func,lines hello.c => a.out

pgprof -s -c

pgprof> select all
pgprof> p
Coverage output - Fri Jan 13 09:33:42 2006
Program   : a.out
Datafile  : pgprof.out
Process : 0
Sort by coverage
Select all

Coverage    Total    Lines    Function
   (%)      Lines  Covered    Name:
-----------------------------------------
  100.0        7        7     main                          (hello.c:3)
pgprof> display all
pgprof> p
Coverage output - Fri Jan 13 09:33:57 2006
Program   : a.out
Datafile  : pgprof.out
Process : 0
Sort by coverage
Select all

Coverage    Total    Lines    Min      Avg      Max    Min    Avg    Max     Function
   (%)      Lines  Covered  Covered  Covered  Covered  Pct    Pct    Pct     Name:
----------------------------------------------------------------------------------------
  100.0        7        7       7        7        7  100.0% 100.0% 100.0%    main                          (hello.c:3)

pgprof> li main

Function: main (hello.c:3)
       Cover(%) :  100.0
    Total Lines :      7
  Covered Lines :      7
   Process      :       0


Covered   Line#
----------------------------------------------------------------------------------------
            1
            2    int main()
            3    {
            4        if (1 == 0) printf ("test");
            4
            5        if (1 == 0)
            6        {
            7          printf ("test");
            8        }
            9        return 0;
           10    }

Ok I’m confused now. Coverage should be 5 lines not 7 in Main. (It is if you bring up the details of the routine.) So it appears to me that the summary is getting the coverage of total executed lines not total lines.

I’ve passed this on to one of our tools engineers to see if he can shed some light as to what’s going on.

Thanks,
Mat

Our tools engineer determined that it’s a bug and he’s filed a techinical problem report (TPR) #3705. It should be fixed in an up coming release. Thanks for finding it.

  • Mat