profiling shared libraries with gprof
Kunal Parmar
kunal.parmar@celunite.com
Fri Apr 20 10:18:00 GMT 2007
Hello,
I am trying to profile a shared library with gprof without much success
and after a lot searching found me no answer, I am asking this question
on the mailing list.
Here are the files I am using :
--- the shared library
#include <stdio.h>
int a(void) {
int i=0,g=0;
while(i++<100000)
{
g+=i;
}
return g;
}
int b(void) {
int i=0,g=0;
while(i++<400000)
{
g+=i;
}
return g;
}
--- the application
#include <stdio.h>
#include <stdlib.h>
int a();
int b();
int main(int argc, char** argv)
{
int iterations;
if(argc != 2)
{
printf("Usage %s <No of Iterations>\n", argv[0]);
exit(-1);
}
else
iterations = atoi(argv[1]);
printf("No of iterations = %d\n", iterations);
while(iterations--)
{
a();
b();
}
}
The steps I follow to compile and run are :
gcc -g -pg -fPIC -c foo.c
gcc -g -pg -shared foo.o -o libfoo.so
gcc bar.c -L/home/kunal/tmp/gprof -Wl,-rpath=/home/kunal/tmp/gprof
-lfoo -o bar
LD_PROFILE=libfoo.so LD_PROFILE_OUTPUT=`pwd` ./bar 10000
This generates the file libfoo.so.profile as expected. But when I run
gprof, I get the following error :
gprof: file `libfoo.so.profile' has unsupported version 131071
I am using gprof version 2.17.
I have attached the code along with a Makefile with this mail. Any help
with this is highly appreciated.
Please add me to the CC list since I have not subscribed to the mailing
list.
Thanks in advance.
--
Kunal Parmar
Tools Team,
Celunite Inc. (www.celunite.com)
More information about the Binutils
mailing list