我正在尝试使用 perf
来分析我的 Android 应用程序。
在 fplutil 的帮助下项目 我设法在 Android 设备上安装 perf,运行 perf record
然后在主机上运行 perf report
。
通常当我运行 perf report -g
时,我希望看到类似于此的调用图:
47.91% a.out a.out [.] f5()
|
--- f5()
|
|--53.82%-- f4()
| |
| |--56.16%-- f3()
| | |
| | |--49.14%-- f2()
| | | |
| | | |--52.92%-- f1()
| | | | a()
| | | | main
| | | | __libc_start_main
| | | |
| | | --47.08%-- a()
| | | main
| | | __libc_start_main
但是,当我对在 Android 设备上收集的数据执行 perf report
时,我没有看到正确的调用图,就像堆栈没有正确展开一样:
4.98% app_name my_lib.so [.] void quat_apply<double>(double*, double const*, double const*, int, double)
|
--- 0xbee75fe4
|
--- 0xbee760c4
|
--- 0xbee75c0c
我应该怎么做才能用函数名替换这些十六进制地址?
我已经在使用 -g
和 -fno-omit-frame-pointer
构建我的代码,我是否遗漏了其他东西?
最佳答案
宾果!
-mapcs-frame
Generate a stack frame that is compliant with the ARM Procedure Call Standard for all functions, even if this is not strictly necessary for correct execution of the code. Specifying -fomit-frame-pointer with this option causes the stack frames not to be generated for leaf functions. The default is -mno-apcs-frame. This option is deprecated.
虽然选项被标记为已弃用,但它为我修复了调用图。
关于android - Perf 无法在 Android 上正确显示调用图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32447923/