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

查看:30
本文介绍了使用 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.

任何帮助将不胜感激!

推荐答案

Instruments 如何获取调试信息:

How Instruments obtains debug information:

Instruments 从 .dSYM 文件中获取调试信息,该文件通常由 XCode 在将调试信息格式设置为 DWARF 时自动生成,dSYM 文件与生成调试符号"选项框中的复选标记相结合.设置这些选项将为 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产生调试信息操作系统的本机格式(刺、 COFF 、 XCOFF 或 DWARF 2).GDB 可以使用此调试信息.在大多数使用stabs 格式,-g 允许使用额外的只有 GDB 的调试信息可以使用;这个额外的信息使在 GDB 中调试效果更好,但会可能使其他调试器崩溃或拒绝阅读程序.如果你想要确定是否要控制生成额外的信息,使用-gstab+、-gstab、-gxcoff+、-gxcoff 或 -gvms(见下文).GCC 允许您可以将 -g 与 -O 一起使用.捷径由优化代码采取的可能偶尔会产生出人意料的结果:您声明的一些变量可能根本不存在;控制流可能会短暂地移动到你没有的地方期待它;有些陈述可能不是执行是因为他们计算恒定的结果或它们的值是已经在手;一些声明可能在不同的地方执行,因为它们被移出循环.
尽管如此,它证明是可能的调试优化的输出.这使它合理地使用优化器可能有错误的程序.

-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 -oMyApp.app.dSYM

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

将 .dSYM 文件放在 mac 的本地驱动器上,然后像往常一样运行 Instruments.

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

重置聚光灯的索引:

如果没有显示符号,可能是因为聚光灯被窃听了.您可以尝试通过将包含 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天全站免登陆