因此,我一直在做以下工作:
$ pprof /bin/ls ls.prof
Using local file /bin/ls.
Gathering CPU profile from http://ls.prof/pprof/profile?seconds=30 for 30 seconds to
/home/user/csteifel/pprof/ls.1414597606.ls.prof
Be patient...
curl: (7) couldn't connect to host
Failed to get profile: curl 'http://ls.prof/pprof/profile?seconds=30' > /home/user/csteifel/pprof/.tmp.ls.1414597606.ls.prof: No such file or directory我不知道这里会发生什么,因为这是他们在这里展示的一个例子:http://google-perftools.googlecode.com/svn/trunk/doc/cpuprofile.html
现在我知道ls并没有真正的信息,但我也知道它不应该给我一个关于卷曲的错误,在这种情况下,它应该是其他的东西。我在这里做错什么了?
我还尝试对我创建的一个示例程序(例如:pprof --callgrind /home/user/csteifel/testing2/X86_64_DEBUG/el6/wtf ~/testing2/prof.out > callgrind.out和我得到一个类似的错误)这样做:
Using local file /home/user/csteifel/testing2/X86_64_DEBUG/el6/wtf.
Use of uninitialized value $host in substitution (s///) at /home/user/csteifel/usr/local/lib/bin/pprof line 3195.
Use of uninitialized value $hostport in concatenation (.) or string at /home/user/csteifel/usr/local/lib/bin/pprof line 3197.
Use of uninitialized value $prefix in concatenation (.) or string at /home/user/csteifel/usr/local/lib/bin/pprof line 3197.
Use of uninitialized value $host in substitution (s///) at /home/user/csteifel/usr/local/lib/bin/pprof line 3195.
Use of uninitialized value $hostport in concatenation (.) or string at /home/user/csteifel/usr/local/lib/bin/pprof line 3197.
Use of uninitialized value $prefix in concatenation (.) or string at /home/user/csteifel/usr/local/lib/bin/pprof line 3197.
Use of uninitialized value $host in sprintf at /home/user/csteifel/usr/local/lib/bin/pprof line 3364.
Gathering CPU profile from http:///pprof/profile?seconds=30 for 30 seconds to
/home/user/csteifel/pprof/wtf.1414597016.
Be patient...
curl: (6) Couldn't resolve host 'http:'
Failed to get profile: curl 'http:///pprof/profile?seconds=30' > /home/user/csteifel/pprof/.tmp.wtf.1414597016.: No such file or directory发布于 2014-11-11 04:14:17
快速回答(以及对我的问题的修正):如果您选择使用环境变量运行探查器的方法1,默认情况下gcc只会忽略您的链接,因为您没有使用来自该库的任何符号。您需要将其包含在-Wl,--no-as-needed标志中,如下所示:
-Wl,--no-as-needed -lprofiler -Wl,--as-needed您可以阅读更多关于它的here。
一个更彻底的答案,并暗示其他潜在的问题:
pprof查找一个名为ls.prof的本地文件,该文件包含有关/bin/ls各种组件运行时的信息(这就是为什么您使用-g标志编译程序的原因,以便它能够看到符号)。
为什么文件不在那?因为它还没有生成!您的/bin/ls尚未使用-lprofiler标志进行编译。如果是的话,并且您通过文档中列出的两种方式之一激活了库:
如果您这样做了,使用库编译ls,每次运行它时,您都会看到如下所示
% ls -la ~
% <output>
% PROFILE: interrupts/evictions/bytes = 204/0/256这意味着概要文件已经生成,现在您可以用
% pprof binary_compiled_with_lprofiler profile_filehttps://stackoverflow.com/questions/26636570
复制相似问题