views:

458

answers:

3

I'm trying to profile a C++ application, that I did not write, to get a sense for where the major computation points are. I'm not a C++ expert and even less so C++ debugging/profiling expert. I believe I am running into a (common?) problem with dynamic libraries.

I compile link to Google CPU Profiler using (OS X, G++):

env LIBS=-lprofiler ./configure
make
make install

I then run profile the installed application (jags) with:

env CPUPROFILE=./jags.prof /usr/local/bin/jags regression.cmd
pprof /usr/local/bin/jags jags.prof

Unfortunately, I get the error:

pprof /usr/local/bin/jags jags.prof Can't exec "objdump": 
No such file or directory at /usr/local/bin/pprof line 2833.

objdump /System/Library/Frameworks/Accelerate.framework/Versions/A/
Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib: No such file or directory

The program dynamically links to libLAPACK.dylib. So prof does not seem to understand it (?). I thought about trying to statically link, but the documents associated with the program say that it is impossible to statically link in LAPACK or BLAS (two required libraries).

Is there a way to have the profiler ignore libLAPACK? I'm okay if it doesn't sample within libLAPACK. Or how might I get profiling to work?

A: 

I don't see a clean way to do it, but maybe there's a hacky workaround -- what happens if you hack the pprof perl script (or better a copy thereof;-), line 2834, so that instead of calling error it emits the message and then does return undef;?

Alex Martelli
+1  A: 

This error was caused by jags being a shell script, that subsequently called profilable code.

pprof /usr/local/bin/REAL_EXEC jags.prof

fixes the problem.

Tristan
A: 

If you're profiling on OSX, the Shark tool is really great as well. It's very simple to use, and has worked out of the box for me when I've tried it.

James Thompson