【发布时间】:2016-10-07 17:08:41
【问题描述】:
我在这个话题上发现了几个相互矛盾的答案。 This 博客文章需要 libuwind,但这在 Mac OS X 上不起作用。我在代码中包含了 #include <google/profiler.h>,但是我的编译器 (g++) 找不到该库。我通过自制软件安装了gperftools。另外,我发现thisstackoverflow 问题显示了这一点:
然后我运行 pprof 来生成输出:
[hidden ~]$ pprof --text ./a.out cpu.profile Using local file ./a.out. Using local file cpu.profile. Removing __sigtramp from all stack traces. Total: 282 samples 107 37.9% 37.9% 107 37.9% 0x000000010d72229e 16 5.7% 43.6% 16 5.7% 0x000000010d721a5f 12 4.3% 47.9% 12 4.3% 0x000000010d721de8 ...
运行该命令(没有任何前面的步骤)让我得到这个:
[hidden]$ pprof --text ./a.out cpu.profile
Using remote profile at ./a.out.
Failed to get the number of symbols from http://cpu.profile/pprof/symbol
为什么它试图访问我机器上的互联网站点和他/她的本地文件?
尝试使用 g++ 将 lib profiler 链接为空运行让我:
[hidden]$ g++ -l libprofiler
ld: library not found for -llibprofiler
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我查看了手册页、帮助选项文本、官方在线指南、博客文章和许多其他来源。
我现在很困惑。有人可以帮我使用 gperftools 吗?
我与@osgx 对话的结果是this script。我试着把它清理一下。它也可能包含很多不必要的选项。
【问题讨论】:
-
嗨,用户 uo... 你能列出通过 homebrew 安装的 gperftools 的所有文件吗(或者只是完整的日志或 make install)?您是如何尝试link 使用 gperftools 库的 cpu profiler 对您的程序进行分析的? (博客错过了这部分,检查goog-perftools.sourceforge.net/doc/cpu_profiler.html“Linking in the Library ..将
-lprofiler添加到可执行文件的链接时间步骤中。(也可能在运行时添加分析器使用LD_PRELOAD,但不一定建议这样做。)") 你有 cpu.profile 文件吗?
标签: c++ macos profiling profile gperftools