分析 C++ 使用 Google Perf 工具和动态库
我正在尝试分析一个不是我编写的 C++ 应用程序,以了解主要计算点在哪里。 我不是 C++ 专家,更不是 C++ 调试/分析专家。 我相信我遇到了动态库的(常见?)问题。
我使用 (OS X, G++):
env LIBS=-lprofiler ./configure
make
make install
然后我运行配置文件已安装的应用程序(jags):
env CPUPROFILE=./jags.prof /usr/local/bin/jags regression.cmd
pprof /usr/local/bin/jags jags.prof
不幸的是,我收到错误:
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
程序动态链接到 libLAPACK.dylib。 所以 prof
似乎不理解它(?)。 我想过尝试静态链接,但与程序相关的文档说不可能在 LAPACK 或 BLAS(两个必需的库)中静态链接。
有没有办法让探查器忽略 libLAPACK? 如果它不在 libLAPACK 中采样我也没关系。 或者我怎样才能让分析发挥作用?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
此错误是由 jag 引起的,它是一个 shell 脚本,随后调用可分析代码。
解决问题。
This error was caused by jags being a shell script, that subsequently called profilable code.
fixes the problem.
我没有看到一个干净的方法来做到这一点,但也许有一个 hacky 解决方法 - 如果你破解 pprof perl 脚本(或者更好的是其副本;-),第 2834 行,会发生什么,这样就不用调用
error
它发出消息,然后返回 undef;
?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 doesreturn undef;
?如果您在 OSX 上进行分析,那么 Shark 工具也确实很棒。 它使用起来非常简单,并且当我尝试过它时,它对我来说是开箱即用的。
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.