使用Instruments分析IPhone应用程序时缺少符号名称 [英] Missing symbol names when profiling IPhone application with Instruments

查看:195
本文介绍了使用Instruments分析IPhone应用程序时缺少符号名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过命令行编译一个IPhone应用程序(因此不涉及XCode选项),并且在使用Instruments进行分析时,我无法显示我的符号名称。我尝试了几个标志,如-gdawrf-2和-g,没有任何成功。我也尝试过使用dsymutils生成一个.dSYM文件,但我不知道我应该如何使用它以便失败。

I am compiling an IPhone application via command line (so no XCode options involved) and I am unable to get my symbol names to show when profiling with Instruments. I have tried several flags such as -gdawrf-2 and -g without any success. I have also tried using dsymutils to generate a .dSYM file but i have no clue how I'm supposed to use it so that failed aswell.

任何帮助都会很大赞赏!

Any help will be greatly appreciated!

推荐答案

Instruments如何获取调试信息:

How Instruments obtains debug information:

工具获得调试来自.dSYM文件的信息,该文件通常由XCode自动生成,当使用dSYM文件将调试信息格式设置为DWARF时,并在生成调试符号选项框中选中复选标记。设置这些选项将为XCode构建过程添加额外的步骤,并在编译应用程序后生成dSYM文件。每个dSYM都使用一个UUID构建,该UUID对应于它所源自的二进制文件中Mach-O部分中的UUID。 Spotlight导入程序会索引Mac上Spotlight可访问位置的每个dSym文件的UUID。因此,SPOTLIGHT会完成所有黑魔法,并负责在您运行的.app和相应的.dSYM文件之间建立链接。

Instruments obtains debug info from a .dSYM file which is normally generated automatically by XCode when setting Debug Information Format to DWARF with dSYM File combined with a checkmark in the Generate Debug Symbols option box. Setting these options will add an extra step to the XCode build process and generate a dSYM file after the application has been compiled. Every dSYM is built with a UUID that corresponds to a UUID in a Mach-O section in the binary that it's derived from. A Spotlight importer indexes the UUIDs of every dSym file that is in a Spotlight-accessible location on your Mac. Therefore SPOTLIGHT does all the black magic and is responsible of making the link between the .app you are running and its corresponding .dSYM file.

如何在没有XCode的情况下生成调试信息和dSYM文件:

How to generate debug information and dSYM file without XCode:

确保使用-gdwarf-编译2和-g标志。 (其他标志组合可能有效)

Make sure you are compilig with –gdwarf-2 and -g flags. (Other flag combinations might work)


-g

生成调试信息操作系统的本机格式
(stabs,COFF,XCOFF或DWARF 2)。
GDB可以使用此调试
信息。在大多数使用
stabs格式的系统上,-g允许使用只有GDB
可以使用的额外
调试信息;这些额外的信息使得
调试在GDB中工作得更好但是
可能会使其他调试器崩溃或
拒绝读取程序。如果
想要控制是否
生成额外信息,请使用
-gstabs +, - gstabs,-gxcoff +, - gxcoff或-gvms(见下文)。 GCC允许
你使用-g和-O。优化代码采用的快捷方式
可能会偶然产生令人惊讶的
结果:您声明为
的某些变量可能根本不存在;控制流量
可能会短暂地移动到你没有预期的
;有些陈述可能不是
执行,因为他们计算
常数结果或者他们的价值已经是b $ b b;一些语句可能
在不同的地方执行,因为
它们被移出循环。

尽管如此,它证明可以
调试优化输出。这使得
合理地将优化器用于可能存在错误的
程序。

-g Produce debugging information in the operating system's native format (stabs, COFF , XCOFF , or DWARF 2). GDB can work with this debugging information. On most systems that use stabs format, -g enables use of extra debugging information that only GDB can use; this extra information makes debugging work better in GDB but will probably make other debuggers crash or refuse to read the program. If you want to control for certain whether to generate the extra information, use -gstabs+, -gstabs, -gxcoff+, -gxcoff, or -gvms (see below). GCC allows you to use -g with -O. The shortcuts taken by optimized code may occasionally produce surprising results: some variables you declared may not exist at all; flow of control may briefly move where you did not expect it; some statements may not be executed because they compute constant results or their values were already at hand; some statements may execute in different places because they were moved out of loops.
Nevertheless it proves possible to debug optimized output. This makes it reasonable to use the optimizer for programs that might have bugs.

-gdwarf-2
以DWARF版本2格式生成调试信息
(如果支持)。这是DBX在IRIX 6上使用的
格式。使用
此选项,GCC在有用时使用
DWARF版本3的功能;
版本3向上兼容
版本2,但可能仍会导致旧版调试器出现
问题。

-gdwarf-2 Produce debugging information in DWARF version 2 format (if that is supported). This is the format used by DBX on IRIX 6. With this option, GCC uses features of DWARF version 3 when they are useful; version 3 is upward compatible with version 2, but may still cause problems for older debuggers.

使用dsymutil生成dSYM文件。如果在命令行中无法识别该工具,请使用聚光灯查找它。
重要提示:如果您正在使用网络驱动器,请在生成dSYM之前将.app文件放在mac HD上。

Generate a dSYM file using dsymutil. If the tool isn't recognized in command line, use spotlight to find it. IMPORTANT: Place .app file on your mac HD before you generate the dSYM if you are working on a networked drive.


dsymutil MyApp.app/MyApp -o
MyApp.app.dSYM

dsymutil MyApp.app/MyApp -o MyApp.app.dSYM

将.dSYM文件放在mac的本地驱动器上像往常一样运行仪器。

Place the .dSYM file on the mac's local drive and run Instruments as you normally would.

重置聚光灯的索引:

如果没有显示符号,可能是因为spotligh被窃听。您可以尝试重新设置聚光灯的索引,方法是将包含dSYM文件(甚至是您的驱动器)的文件夹添加到聚光灯首选项中的防止聚光灯搜索这些位置,然后立即将其删除。

If symbols aren't shown, it might be because spotligh is bugged. You can try reseting spotlight's indexing by adding your folder containing the dSYM file (or even your drive) to the "Prevent spotlight from searching these locations" in the spotlight preferences and then removing it right away.

这篇关于使用Instruments分析IPhone应用程序时缺少符号名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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