gprof : How to generate call graph for functions in shared library that is linked to main program

gprof won’t work, you need to use sprof instead. I found these links helpful: How to use sprof? http://greg-n-blog.blogspot.com/2010/01/profiling-shared-library-on-linux-using.html Summary from the 2nd link: Compile your shared library (libmylib.so) in debug (-g) mode. No -pg. export LD_PROFILE_OUTPUT=`pwd` export LD_PROFILE=libmylib.so rm -f $LD_PROFILE.profile execute your program that loads libmylib.so sprof PATH-TO-LIB/$LD_PROFILE $LD_PROFILE.profile -p >log See the … Read more

What is -no-pie used for?

That flag is telling gcc not to make a position independent executable (PIE). PIE is a precondition to enable address space layout randomization (ASLR). ASLR is a security feature where the kernel loads the binary and dependencies into a random location of virtual memory each time it’s run.

gprof and arguments to executable

You don’t run your executable with gprof, so you only specify it so gprof can load symbols. You run the executable first, on its own just as normal, and it then emits profiling data. This data is loaded, along with the executable, by gprof later. This is all explained in the gprof manual, of course.

How does GCC’s ‘-pg’ flag work in relation to profilers?

Compiling with -pg instruments your code, so that Gprof reports detailed information. See gprof’s manual, 9.1 Implementation of Profiling: Profiling works by changing how every function in your program is compiled so that when it is called, it will stash away some information about where it was called from. From this, the profiler can figure … Read more

Alternatives to gprof [closed]

gprof (read the paper) exists for historical reasons. If you think it will help you find performance problems, it was never advertised as such. Here’s what the paper says: The proļ¬le can be used to compare and assess the costs of various implementations. It does not say it can be used to identify the various … Read more