9

please explain with example?

kazanaki
  • 7,988
  • 8
  • 52
  • 79
  • see http://stackoverflow.com/questions/1838989/gprof-how-to-generate-call-graph-for-functions-in-shared-library-that-is-linked/4959168#4959168 – Dan Feb 10 '11 at 16:03

1 Answers1

8

From the emails found here and here, I've extracted the following notes:

Given an application my_app', which links against a shared objectmy_sobj', and has been compiled with the '-g' compile flag:

#set the environment variable LD_PROFILE to the name of the shared obj
export LD_PROFILE=my_obj
#run your application
my_app
#this should create a file /var/tmp/my_sobj.profile
#now run sprof
sprof my_sobj my_sobj.profile

This gives profile information for the shared library, not for my_app

Shannon Nelson
  • 2,090
  • 14
  • 14
  • does this only work for libc stuff? Or can I use it on my own compiled shared libraries? – jdizzle Aug 06 '09 at 17:24
  • 1
    "no PLTREL found in object" is the error I get when trying to profile my own library. What do I need to do at compile/link time to include the required information? – jdizzle Aug 06 '09 at 17:33