This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

sprof failed to load shared object


Hello,

I am trying to profile a shared library. 
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`pwd` -Wl,-rpath=`pwd` -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
sprof, I get the following error :
sprof: failed to load shared object `libfoo.so'

sprof was run as:
LD_LIBRARY_PATH=`pwd` sprof libfoo.so libfoo.so.profile

sprof version is - sprof (GNU libc) 2.4

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)



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]