How do you profile an executable that loads shared libraries?

Tristan Gingold gingold@adacore.com
Mon Feb 23 08:54:00 GMT 2009


On Feb 20, 2009, at 6:00 PM, Mike Frysinger wrote:

> On Friday 20 February 2009 10:33:37 Nick Clifton wrote:
>>> I have an executable that loads shared libraries. I compiled with  
>>> "-g
>>> -pg" and then I ran gprof on the gmon.out file. I don't see any of  
>>> the
>>> shared libraries that the program loaded in my gprof output. How do
>>> you profile shared libraries?
>>
>> It seems that this is no longer possible. :-(  Perhaps you could try
>> another profiling tool (eg oprofile) or else using static libraries.
>
> just curious, but how so ?  if the -pg code simply adds calls to  
> mcount at
> every function entry, why would shared libs matter ?

-pg not only adds calls to mcount but also enable the use of profil(2)  
(or SIGPROF).  This syscall
makes kernek update counts in the samples buffer which represent one  
address ranges.  With shared libraries
you have many addresses ranges.
Some systems (such as Solaris) have an alternate method that works  
with shared libraries.



More information about the Binutils mailing list