为什么循环摘要在 gprof 的调用图输出中没有任何调用者?
我使用 GNU gprof 2.15.94.0.2.2 对我的 C++ 程序进行分析,该程序具有较大的调用周期。 我期望在调用图输出中看到类似下面的内容 gprof 的文档表明:
index % time self children called name
----------------------------------------
1.77 0 1/1 main [2]
[3] 91.71 1.77 0 1+5 <cycle 1 as a whole> [3]
1.02 0 3 b <cycle 1> [4]
0.75 0 2 a <cycle 1> [5]
0 0 6/6 c [6]
----------------------------------------
但是,我的
条目都没有列出任何调用者。 它们都是这样的:
index % time self children called name
----------------------------------------------
[8] 65.6 259.55 5342.63 9334767+60122608 <cycle 2 as a whole> [8]
133.28 2051.45 12043564+74015448 foo <cycle 2> [14]
18.90 976.38 2379645 bar <cycle 2> [21]
...
-----------------------------------------------
由于我的循环非常大,因此很难通过循环中的各个函数来跟踪调用者。
谁能告诉我为什么循环调用者在输出中丢失,以及如何让它们出现?
I use GNU gprof 2.15.94.0.2.2 to do profiling of my C++ program, which has large call cycles. I expected to see something like below in the call graph output as gprof's documentation indicates:
index % time self children called name
----------------------------------------
1.77 0 1/1 main [2]
[3] 91.71 1.77 0 1+5 <cycle 1 as a whole> [3]
1.02 0 3 b <cycle 1> [4]
0.75 0 2 a <cycle 1> [5]
0 0 6/6 c [6]
----------------------------------------
However, none of my <cycle as a whole>
entries have any callers listed. They are all like this:
index % time self children called name
----------------------------------------------
[8] 65.6 259.55 5342.63 9334767+60122608 <cycle 2 as a whole> [8]
133.28 2051.45 12043564+74015448 foo <cycle 2> [14]
18.90 976.38 2379645 bar <cycle 2> [21]
...
-----------------------------------------------
Since my cycles are quite large, it is very hard to trace the callers via individual functions in a cycle.
Can anyone tell me why the cycle callers are missing in the output, and how to make them show up?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的应用程序使用多线程吗? gprof 根本不支持线程。 否则,您很可能遇到了 gprof 中的错误。 它充满了错误并且已经过时了。 最好使用 oprofile 或 valgrind 之类的东西。
Does your application use multithreading? gprof doesn't work with threads at all. Otherwise, you may very likely have hit a bug in gprof. It's bug ridden and obsolete. Better use something like oprofile or valgrind.
我什至将其称为 gprof 中的错误。 我设置了一个相互递归函数的简单示例,并得到了与您完全相同的行为。 我有 Functions:
和 main():
我尝试将对 a() 的调用替换为:
希望 gprof 能够比 main() 的调用更好地注册对 d() 的循环的调用,但我得到了相同的结果。
我还用 printf() 替换了 cout 并编写了一个 C 程序,与循环中没有列出调用者的结果相同。
I'm going to go so far as to call this a bug in gprof. I set up a simple example of mutually recursive functions and got the exact same behavior you did. I had functions:
and a main():
I tried replacing the call to a() with:
in the hopes that gprof would register a call to the cycle from d() better than the call from main(), but I got the same result.
I also replaced the cout with printf() and made a C program, with the same results of no caller listed for the cycle.
这是您主要关心的问题,还是您有更大的目标,例如尝试找到可以优化的东西? 通常,这就是人们使用 gprof 的原因。
gprof就是这样,但你可以做得更好。
Is this your main concern, or do you have a larger goal, like trying to find things you can optimize? Usually, that's why people use gprof.
gprof is what it is, but you can do better.