This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
RE: gprof/sprof and shared libraries...again
- From: "Braman, Paul" <Paul_Braman at tvratings dot com>
- To: "'binutils at sources dot redhat dot com'" <binutils at sources dot redhat dot com>
- Date: Thu, 4 Apr 2002 14:20:41 -0500
- Subject: RE: gprof/sprof and shared libraries...again
On Thursday, April 04, 2002 1:45 PM, Ulrich Drepper wrote:
>
> On Thu, 2002-04-04 at 10:27, Braman, Paul wrote:
> >
> > The question then becomes, "How do I profile the calls made *to*
> > libprof.so?"
>
> LD_PROFILE intercepts the calls to every exported interface in a DSO.
> Nothing else, nothing more.
Sounds like you are saying, "use LD_PROFILE". Unless I read that wrong,
your reply answers my exact question. (Yes, that's a pretty obvious
statement.)
I used LD_PROFILE (you can see it in the original example). It doesn't
profile calls made to the exported interface in libprof.so (DSO). I'm
trying to figure out why. (You can view my testbed at the bottom of this
email.)
Unless I am missing something I don't think I'm asking unreasonable
questions. Feel free to point out errors in my process or in my thinking.
Paul Braman
Paul_Braman@tvratings.com
==== prof.h ====
#ifndef __prof_h__
#define __prof_h__
unsigned int something (volatile unsigned int count);
#endif // __prof_h__
================
==== prof.c ====
#include <prof.h>
unsigned int something (volatile unsigned int count) {
unsigned int value = 0;
while (count--) {
++value;
}
return value;
}
================
==== ptest.c ====
#include <prof.h>
static unsigned int nothing (volatile unsigned int count) {
unsigned int value = 0;
while (count--) {
++value;
}
return value;
}
int main () {
unsigned int n = nothing (50000000);
unsigned int s = something (50000000);
return ((n + s) % 131071);
}
=================
export LD_PROFILE=libprof.so
export LD_PROFILE_OUTPUT=.
gcc -fPIC -I. -c -o prof.lo prof.c
gcc --shared -o libprof.so prof.lo
gcc -pg -I. -c -o ptest.o ptest.c
gcc -pg -o ptest ptest.o -L. -lprof -Xlinker -rpath -Xlinker .
gprof shows a profile of the call to nothing()
sprof does not show a profile of the call to something()