使用 Instruments 分析 iPhone 应用程序时缺少符号名称

发布于 2024-08-31 03:29:00 字数 195 浏览 7 评论 0原文

我正在通过命令行编译 iPhone 应用程序(因此不涉及 Xcode 选项),但是在使用 Instruments 进行分析时,我无法显示符号名称。

我尝试了多个标志,例如 -gdawrf-2-g 但没有成功。我还尝试使用 dsymutil 生成 .dSYM 文件,但我不知道应该如何使用它,所以也失败了。

I am compiling an iPhone application via command line (so no Xcode options involved) however 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 dsymutil to generate a .dSYM file but I have no clue how I'm supposed to use it so that failed as well.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

ゝ偶尔ゞ 2024-09-07 03:29:00

我将项目设置更改为在构建时不包含 dSYM 文件:

在此处输入图像描述

将其更改为包含 dSYM 文件有帮助探查器对符号进行去符号化并解决了我的问题:

在此处输入图像描述

I Changed my project settings to not include the dSYM file while building:

enter image description here

Changing it to include the dSYM File helped the profiler desymbolize the symbols and fixed my issue:

enter image description here

泛滥成性 2024-09-07 03:29:00

我对此仍然有疑问。

我的问题是我能够看到正在生成的 dSYM 文件,但 Instruments 没有拾取它。

要解决此问题,请执行以下操作:

  1. 找到您的 dSYM 文件(应位于 ~/Library/Developer/DerivedData/APP_NAME-XXXXXXX/Build/Products/[BUILD_TYPE]-[DEVICE-TYPE]/
  2. 停止 Instruments 的情况下,单击 File - > 重新符号化文档
  3. 向下滚动到包含您的应用程序名称的条目
  4. 单击“查找”并选择步骤 1 中的文件夹
  5. 单击“开始”按钮开始分析

I was still having issues with this.

My issue was I was able to see the dSYM file being generated, but Instruments wasn't picking it up.

To fix this, do the following:

  1. Locate your dSYM file (should be in ~/Library/Developer/DerivedData/APP_NAME-XXXXXXX/Build/Products/[BUILD_TYPE]-[DEVICE-TYPE]/
  2. With Instruments stopped, click on File -> Re-Symbolicate Document
  3. Scroll down to the entry with your app name
  4. Click "Locate" and choose the folder from step 1
  5. Click the Start button to begin profiling
淡淡の花香 2024-09-07 03:29:00

Instruments 如何获取调试信息:

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

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

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

-g
产生调试信息
操作系统的本机格式
(刺、 COFF 、 XCOFF 或 DWARF 2)。
GDB可以使用此调试
信息。在大多数使用的系统上
sats 格式,-g 允许使用额外的
只有GDB的调试信息
可以使用;这些额外的信息使得
调试在 GDB 中工作得更好,但会
可能会使其他调试器崩溃或
拒绝阅读该程序。如果你
想要确定是否要控制
生成额外信息,使用
-gstabs+、-gstabs、-gxcoff+、-gxcoff 或 -gvms(见下文)。海湾合作委员会允许
您可以将 -g 与 -O 一起使用。捷径
优化代码可能会采取
偶尔会产生令人惊讶的
结果:您声明的一些变量
可能根本不存在;控制流程
可能会短暂移动到您没有移动的地方
期待它;有些陈述可能不是
执行是因为他们计算
恒定的结果或其值是
已经在手边;有些陈述可能
在不同的地方执行,因为
他们被移出了循环。
尽管如此,事实证明有可能
调试优化输出。这使得
合理使用优化器
可能有错误的程序。

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

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

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

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

重置聚光灯的索引:

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

How Instruments obtains debug information:

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.

How to generate debug information and dSYM file without XCode:

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

-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
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.

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

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

Resettig spotlight's indexing:

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.

烟火散人牵绊 2024-09-07 03:29:00

在 Xcode 4.5 中,您可以选择从调试或发布版本进行分析。 Release 默认在复制到设备时剥离符号。可以非常轻松地切换到调试配置进行分析,而无需破坏发布配置。为此,请选择产品 ->从 XCode 菜单编辑方案。从出现的方案列表中选择“配置文件”,然后为其选择正确的构建配置。

或者,您可以进行单独的发布/配置文件配置,并在方案的配置文件部分中使用它。 XCode 用户指南

In Xcode 4.5 you can choose to Profile from Debug or Release builds. Release defaults to stripping the symbols when copied to the device. It's very easy to switch to the Debug configuration for profiling without breaking your release configuration. To do that, select Product -> Edit Scheme from the XCode menu. Select "Profile" from the list of schemes that comes up, and then select the correct Build Configuration for that.

Or you could make a separate release/profile configuration and use that in your Profile section of your scheme. How to add a separate build configuration is described in the XCode User Guide.

末骤雨初歇 2024-09-07 03:29:00

使用Xcode 6 Instruments,您可以提供dSYM文件,如下所示:

  • 文件 -> Symbols... 菜单(当分析停止时)
  • 选择您的应用程序,然后按Locate按钮
  • 选择包含 dSYM 的路径(通常~/Library/Developer/DerivedData/APP_NAME-XXXXXXX /Build/Products/[BUILD_CONFIGURATION]-[TARGET_PLATFORM]/)。 提示:您可以从终端复制此路径并在对话框中使用 OS X 快捷键 ⌘+SHIFT+G

此外,Instruments 会询问您将来是否应该使用选定的路径来尝试为此应用程序加载 dSYM。回答 是的:)

With Xcode 6 Instruments you can provide dSYM file as follow:

  • File -> Symbols... menu (when profiling is stopped)
  • select your app and press Locate button
  • select path which contains dSYM (usually ~/Library/Developer/DerivedData/APP_NAME-XXXXXXX/Build/Products/[BUILD_CONFIGURATION]-[TARGET_PLATFORM]/). Tip: You can copy this path from terminal and use OS X shortcut ⌘+SHIFT+G in dialog.

Also Instruments will ask you if it should use selected path to try load dSYM for this app in the future. Answer Yes :)

那小子欠揍 2024-09-07 03:29:00

花了三天时间尝试解决 Xcode 7.1/7.3 的问题...将

部署目标更改为最新版本(当时为 9.3)为我解决了这个问题。我的公司的目标是 7.0,因此我可能必须创建一个自定义方案来分析 Instruments 中的代码,以避免在我们进行生产发布时必须更改目标(或忘记更改目标)。

如果 dSYM 无法根据部署目标工作,似乎这可能是一个错误?

Spent three days trying to figure this out for Xcode 7.1/7.3...

Changing the deployment target to the latest version (9.3 at the time) fixed this issue for me. My company targets 7.0 so I will probably have to create a custom Scheme for profiling the code in Instruments to avoid having to change the target (or forgetting to change the target) when we do a production release.

Seems like it's probably a bug if dSYMs fail to work based on the deployment target?

橘虞初梦 2024-09-07 03:29:00

根据我的经验,这通常是因为在目标设备上安装应用程序的最新修改版本之前调用了“配置文件”。

尝试在设备/目标上运行应用,然后在重新安装后再次调用“配置文件”。

In my experience, this is usually because "Profile" has been called before the most recently modified version of the app has been installed on the target device.

Try running the app on the device/target, then calling "Profile" again after it has been reinstalled.

只是偏爱你 2024-09-07 03:29:00

问题是聚光灯找不到 .dSYM 文件。
这是因为 Apple 更改了 DerivedData 文件夹的位置。
DerivedData 现在进入 ~/Library

Spotlight 不会索引 ~/Library 并且据我所知,也无法对其建立索引(例如 mdimport被忽略)。

在分析器中获取符号的一种解决方法是简单地将数据复制到 ~/Library 之外,例如您的主目录就可以了。

我使用了这个命令行:

$ cp -r ~/Library/Developer/Xcode/DerivedData/AppName-xxxxxxxxxxx/Build/Products/Release-iphoneos/ ~/

当您终止探查器并开始新的探查器运行时,您将看到这些符号再次可用。

The problem is that spotlight cannot find the .dSYM files.
This is because Apple changed the location of the DerivedData folder.
The DerivedData now goes in ~/Library

Spotlight will not index ~/Library and as far as I have been able to establish, cannot be made to index it either (e.g. mdimport is ignored).

A work around to get symbols in your profiler, is to simply copy the data outside ~/Library e.g. your home directory will do fine.

I used this command line:

$ cp -r ~/Library/Developer/Xcode/DerivedData/AppName-xxxxxxxxxxx/Build/Products/Release-iphoneos/ ~/

When you kill your profiler, and start a new profile run, you will see that the symbols are available again.

路弥 2024-09-07 03:29:00

检查构建日志并确保您的 -g 开关已到达编译器 - 在更改项目和/或目标级别的不同构建配置等设置时很容易出错。

Check the build log and make sure that your -g switch is getting through to the compiler - it's easy to get this wrong when changing settings at the project and/or target levels for different build configurations etc.

余生一个溪 2024-09-07 03:29:00

Xcode 4 附带的 Instruments 版本中的另一个解决方法是使用 Instruments 文件菜单下的重新符号化文档菜单项。此菜单项允许您使用位于 ~/Library/... 目录中的 .dSYM 文件中的符号。

Another work around in the version of Instruments that comes with Xcode 4 is to use the Re-Symbolicate Document menu item under the File menu for Instruments. This menu item to allows you to use the symbols located in the .dSYM file in ~/Library/... directory.

空城旧梦 2024-09-07 03:29:00

我遇到这个问题是因为 XCode 项目位于网络共享上,Spotlight 找不到 dSYM 文件。确保它位于本地驱动器上。

I got this problem because the XCode project was on a network share where Spotlight wouldn't find the dSYM files. Make sure it's on the local drive.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文