gprof 图书馆 - 问题

发布于 2024-08-24 18:13:11 字数 278 浏览 1 评论 0原文

我需要 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

白龙吟 2024-08-31 18:13:11

您可以比 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.

诗酒趁年少 2024-08-31 18:13:11

我有同样的问题,但我认为最好的办法是创建一个小型 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文