Line number in Google Perftools CPU profiler on MacOSX

我的梦境 提交于 2019-12-02 18:26:54

This seems to be related to the address space layout randomization (ASLR) introduced in OS X 10.5

I've filed issue #562 on the gperftools issue tracker. You can disable ASLR by passing -Wl,-no_pie.

Also, if you're not bound to use gperftools, Instruments (comes with Xcode) is worth a try.

Miguel

I believe in this platform the debug symbols stay in the .o file(s), they are not moved to the executable. To get symbols in gdb or profilers you need to save the .o files. This may mean that you need to compile your application in two steps (compile, then link) to preserve the .o files.

See this question for additional information.

In looking at the pprof Perl source code, symbol names are obtained via the use of nm and c++filt, so you could try to run those standalone and figure out why they don't work. From the pprof source it looks like it tries a bunch of different command line arguments to cover several versions of nm. This is a summary of the ways

nm [-D] -n [-f] [--demangle] object-file 2>/dev/nul [| cpp+filt]

The parts that I put in brackets are those that the script determines at runtime if are required for your platform and versions of nm and c++filt. Try all the combinations of the above and see what works. Then look at what the pprof script does, maybe by adding some printfs to it.

Good luck.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!