Re: Odd profiler behaviour (gcc -pg/gprof)

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

 



On 1/23/2013 6:56 PM, Nikhil Nair wrote:

I'm using a current version of Ubuntu server, with gcc 4.6.3 and gprof 2.22. I've been getting decidedly odd results in profiling a program; I'm new to profiling, but I've looked at the info documentation, and this doesn't seem to be mentioned.

The issue is that most of the execution time seems to be missing. I've installed the libc-prof package to give me profiling libraries; I've used -pg for both compiling and linking, and tried leaving out optimizations. No change.

The program runs for over a minute, and (according to /usr/bin/time) is roughly divided 50/50 between user and system, and running at 99% CPU. However, the total CPU time reported in the flat profile is less than 10 seconds. Also, there's no mention of system calls (I use fread() quite a bit, and would have thought that, or one of the related primitives, would be mentioned somewhere...).

According to any information I've seen, the requirements for linking libc-prof specifically include static options:
http://buildd.emdebian.org/debian/eglibc/branches/glibc-branch-lenny/debian/debhelper.in/libc-prof.README.Debian
If you didn't heed this and linked against a .so, not seeing the time spent in libraries could hardly be termed "odd."

Profilers I'm familiar with which deal with .so require the specific paths to the .so to be designated during the analysis phase. I'm not aware of such a facility in gprof, although one would think that library functions which are built with -pg should record their activity in gmon.out. You might check whether the library functions of interest appear in your libc_p; if not, and the information obtained by static link (if you have libc.a) isn't sufficient, you may need to build it yourself.

--
Tim Prince



[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