如何在不分析主机应用程序的情况下分析共享对象?

发布于 2024-08-18 22:07:04 字数 435 浏览 1 评论 0原文

我有一个主机应用程序,并且编写了一个插件。我将插件编译为共享对象(例如 foo.so),主机应用程序将通过 dlopen 加载它。在这种情况下,我的主机应用程序是来自 llvm 的 opt 工具(尽管我认为这对这个问题并不重要)。

我想在启用分析的情况下编译我的插件(即 g++ -pggprof)。但是,当我这样做时,配置文件输出文件 gmon.out 永远不会创建。也许 gprof 希望有人调用设置例程或类似的东西。

由于各种原因,我想避免使用 -pg 重新编译主机应用程序。我很好奇是否可以在不分析主机应用程序 opt 的情况下分析共享对象 foo.so 。

我还研究了其他分析工具; HP 的 qprof 应该能够处理这种情况,但它无法解析共享对象中的函数名称(它以一种非常幼稚的方式回退到 addr2line)。

谢谢, 缺口

I have a host application and I have written a plug-in. I compile my plug-in down to a shared object (say foo.so), and the host application will load it via dlopen. In this case, my host application is the opt tool from llvm (though I don't think that's important to the question).

I'd like to compile my plug-in with profiling enabled (i.e. g++ -pg, gprof). However, when I do this, the profile output file gmon.out is never created. Maybe gprof expects someone to call a setup routine, or something like that.

For various reasons, I would like to avoid recompiling the host app with -pg. I am curious if it is possible to profile a shared object foo.so without profiling the host application opt.

I've also looked into other profiling tools; qprof from HP should be able to handle this situation, but it is unable to resolve the names of functions in the shared object (it falls back to addr2line in a very naive way).

Thanks,
Nick

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

多情出卖 2024-08-25 22:07:04

我认为您想要这样做的原因是找到优化插件的方法(而不是仅仅获取计时信息)。

您可以在调试器或 IDE 下运行主机应用程序吗? IDE 是否有暂停按钮,或者您可以使用 Ctrl-C 或类似的键来中断它吗?

然后,您可以使用此技术快速找到成本高昂的代码。仅在插件运行时才采集样本,或者如果您无法做到这一点,请忽略不以插件结尾的样本。

即使您使用 gprof 或类似的分析器,您我们可能会失望

I assume the reason you want to do this is to find ways to optimize the plugin (as opposed to just getting timing information).

Can you run the host app under a debugger or IDE? Does the IDE have a pause button, or can you interrupt it with Ctrl-C or some such key?

Then you can quickly find the costly code by using this technique. Only take samples when your plugin is running, or if you can't do that, just ignore samples that don't end in your plugin.

Even if you get gprof to work, or a similar profiler, you're likely to be disappointed.

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