Mac OSX中的Google Perftools CPU分析器中的行号 [英] Line number in Google Perftools CPU profiler on MacOSX

查看:955
本文介绍了Mac OSX中的Google Perftools CPU分析器中的行号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在MacOSX上配置一些C ++程序。所以我创建了 google-perftools ,编写了一个程序,使用MacPorts g ++ 4.7编译,使用 -g 编译器标志,链接到 libprofiler 。然后我运行:

I am trying to profile some C++ programs on MacOSX. So I built google-perftools, wrote a program, compiled using MacPorts g++ 4.7, with -g compiler flag, and linked to libprofiler. Then I ran:

CPUPROFILE=cpu.profile ./a.out

然后我运行pprof生成输出:

Then I ran pprof to generate the output:

[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
      11   3.9%  51.8%       11   3.9% 0x000000010d721a4e
       9   3.2%  55.0%        9   3.2% 0x000000010d721e13
       8   2.8%  57.8%        8   2.8% 0x000000010d721a64
       7   2.5%  60.3%        7   2.5% 0x000000010d7222f0
       6   2.1%  62.4%        6   2.1% 0x000000010d721a4c
       6   2.1%  64.5%        6   2.1% 0x000000010d721b1f
       6   2.1%  66.7%        6   2.1% 0x000000010d721e0c
       5   1.8%  68.4%        5   1.8% 0x000000010d721fba
    ......

看起来perftools不会转换地址到函数名。

It looks like the perftools don't convert the addresses to function names.

有没有人知道我在这里丢失了什么?我应该怎么做让分析器生成正确的结果。

Does anyone know what I am missing here? What should I do to let the profiler generate the correct result.

编辑:更多信息:这不是pprof或google-perftools的问题,但更像gcc或macosx,因为Instrument.app也显示地址而不是行号。我不熟悉调试符号如何在Mac OS X下工作,所以我宁愿认为它是我缺少的东西在这里,而不是在gcc或Mac OS X中的错误。我想知道是否有人可以提供一些提示如何调试信息工作

More information: it is not a problem of pprof or google-perftools, but more something like gcc or macosx, because Instrument.app also shows addresses instead of line numbers. I am not familiar with how debug symbols work under Mac OS X, so I would rather think it as my missing something here, instead of being bugs in gcc or Mac OS X. I wonder whether anyone can provide some hints on how debug info works for Mac OS X.

推荐答案

这似乎与地址空间布局随机化 )在OS X 10.5中引入

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

我已提交问题#562 在gperftools问题跟踪器。您可以通过传递 -Wl,-no_pie 禁用ASLR。

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

此外,如果您不必使用 gperftools Instruments (自带 Xcode )尝试。

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

这篇关于Mac OSX中的Google Perftools CPU分析器中的行号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆