[comp.bugs.sys5] Static limits in SVr2 profil

mario@hcr.UUCP (Mario Ruggiero) (11/10/89)

[Due to a switchover in our news software, this article may not have been
posted the first time.  My apologies to anyone who gets it twice.]

> When the text size of an a.out file exceeds approx. 60-70Kb profil(2)
> does not seem to work correctly. Prof(1) reports that a large percentage
> of the CPU time was spent in functions that I never call, functions I call
> a lot don't even show up as using CPU.  The function counters are correct 
> however, only the CPU usage is wrong.

This problem may be generic to System V.  We recently looked at this
and found that the arithmetic that scales values of the program counter
into the profil data area has some hard coded 16-bit dependencies in it.
Consequently, it will not work correctly once the profil data area is
larger than 64K.  I believe that the default data area allocated with the
cc -p option is the same size as the text segment, so you are probably
running into this problem.  It is possible to call monitor(3) directly
and specify a buffer of a different size.

Incidentally, we also discovered a fairly serious problem in the prof
utility which can also cause some of the symptoms you reported.  Because
of the bizarre way that the symbols from the a.out are processed, prof
can sometimes miss the last ``few.''  Any time spent by the program in
these routines will be attributed to the closest entry point that prof
didn't miss; this can cause CPU time to be wildly misallocated.  If this
problem is occurring, the missed routines will not appear in the output
at all.  There is not much that can be done to get around the problem;
using the prof -g option may help somewhat in that additional symbols
are considered, so the set that is dropped may be different.

Mario Ruggiero
HCR Corporation