gprof 图书馆 - 问题
我需要 gprof 我们系统中的一个库来检查函数调用,看看我们是否可以进一步优化它。基本上,我拥有的是
可执行文件 A,它使用共享库 myLib.so
我想 gprof myLib.so。当我使用 -pg 选项编译 myLib.so 源时,它会生成一个 .so 文件。
但是,由于某种原因,针对该库重新编译可执行文件 A 不会生成 *.gmon 文件。需要做什么?我应该静态链接 myLib 吗?如果是这样,请告诉我怎么做。我是新手,请原谅我的无知。我每天都在学习,
提前致谢。
I need to gprof a library in our system to examine the function calls and see if we can optimize it any more. Basically, what I have is
Executable A which uses a shared Library myLib.so
I want to gprof the myLib.so. When I compile myLib.so source using -pg option, it produces a .so file just fine.
But, recompiling the Executable A against that library is not producing the *.gmon file for some reason. What needs to be done? Should I link the myLib statically? If so, please tell me how. I am a newbie, so pardon my ignorance. I am learning everyday
thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以比 gprof 做得更好。
您可以使用良好的采样分析器,例如 RotateRight/Zoom,或者您可以尝试 这种技术。 lsstack 也很好用。 pstack 也可以,但对你来说需要做更多的工作。
You can do better than gprof.
You could use a good sampling profiler like RotateRight/Zoom, or you could try this technique. Also lsstack serves well. pstack does too, but is more work for you.
我有同样的问题,但我认为最好的办法是创建一个小型 C/C++ 程序,该程序使用该库进行一些测试调用,使用 -pg 与该库一起编译它,并对其进行分析。
这样,您也可以很好地将库的分析问题与其他内容隔离开来。
作为http://sourceware.org/binutils/docs/gprof/Implementation.html 和 https://stackoverflow.com/a/7290284/885650 指出,链接时需要 -pg ,因为它到处都添加了额外的代码。
I have the same issue, but I think the best thing to do is to create a small C/C++ program that uses the library with some test calls, compile it with the library using -pg, and profile that.
That way you nicely isolate the profiling issues of the library from other stuff, too.
As http://sourceware.org/binutils/docs/gprof/Implementation.html and https://stackoverflow.com/a/7290284/885650 point out, you need -pg when linking, as it adds extra code everywhere.