Xcode 4 Instruments 不显示源代码行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5268041/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode 4 Instruments doesn't show source lines
提问by Marcelo Cantos
I've just started playing with Xcode 4, and found that, no matter how I setup debugging symbols in the project, Instruments refuses to display source lines for stack trace items that correspond to my code. In only shows hex offsets and identifies my executable as the owning module. Turning on "Source Location" draws a blank too. This occurs even for the skeleton OpenGL ES project generated by Xcode (File → New → New Project... → iOS → Application → OpenGL ES Application).
我刚刚开始使用 Xcode 4,发现无论我如何在项目中设置调试符号,Instruments 都拒绝显示与我的代码对应的堆栈跟踪项的源代码行。In 仅显示十六进制偏移量并将我的可执行文件标识为拥有模块。打开“源位置”也会画一个空白。即使对于由 Xcode 生成的骨架 OpenGL ES 项目(文件 → 新建 → 新建项目... → iOS → 应用程序 → OpenGL ES 应用程序)也会发生这种情况。
This problem only occurs in Instruments (I've tried CPU and OpenGL tracing so far). Gdb picks up debug symbols just fine.
这个问题只发生在仪器中(到目前为止我已经尝试过 CPU 和 OpenGL 跟踪)。Gdb 可以很好地提取调试符号。
Do I have to do something special to see the source code for stack traces in Instruments, or is this a bug in Xcode 4?
我是否必须做一些特殊的事情才能在 Instruments 中查看堆栈跟踪的源代码,或者这是 Xcode 4 中的错误?
So far, I've:
到目前为止,我已经:
- Changed
Debug Information Format
fromDWARF with dSYM File
toDWARF
. - Changed
Strip Debug Symbols During Copy
fromYes
toNo
. - Changed the build scheme to use the Debug build instead of the Release build with Instruments.
- 改变
Debug Information Format
从DWARF with dSYM File
到DWARF
。 - 改变
Strip Debug Symbols During Copy
从Yes
到No
。 - 将构建方案更改为使用调试构建而不是使用仪器发布构建。
回答by Phil Calvin
The other answers are good long-term fixes. If you'd rather not wait for Spotlight to rebuild its index and just need to get symbols for one Instruments session, you can ask Instruments to symbolicate the current session.
其他答案是良好的长期修复。如果您不想等待 Spotlight 重建其索引而只需要获取一个 Instruments 会话的符号,您可以要求 Instruments 对当前会话进行符号化。
- Choose File → Re-Symbolicate Document…
- Locate your binary in the list that appears. It should be the same name you see on the Springboard. Select your binary and click "Locate."
- Go back to Xcode. Control-click on your .app build product and choose "Show in Finder".
- This will reveal the directory containing your binary as well as its
dSYM
file. Go back to Instruments, navigate to this directory, and select yourdSYM
file. The easiest way is to just drag thedSYM
file straight from the Finder to the "Select dSYM" dialog in Instruments. - Finally, click "Symbolicate" in Instruments. You should now see symbols in the traces rather than hex offsets.
- 选择文件→重新符号化文档...
- 在出现的列表中找到您的二进制文件。它应该与您在 Springboard 上看到的名称相同。选择您的二进制文件,然后单击“定位”。
- 回到Xcode。按住 Control 键单击您的 .app 构建产品,然后选择“在 Finder 中显示”。
- 这将显示包含二进制
dSYM
文件的目录及其文件。返回 Instruments,导航到此目录,然后选择您的dSYM
文件。最简单的方法是将dSYM
文件直接从 Finder拖到Instruments 中的“Select dSYM”对话框中。 - 最后,单击 Instruments 中的“Symbolicate”。您现在应该在跟踪中看到符号而不是十六进制偏移。
回答by JonnyBoy
I had this issue today and solved it this way:
我今天遇到了这个问题并通过以下方式解决了它:
- Edit scheme
- Click on "Profile" on the left (this is the important step)
- Change Build Configuration to Debug
- 编辑方案
- 点击左侧的“个人资料”(这是重要的一步)
- 将构建配置更改为调试
That should do it. Note that for whatever reason, the build target is not set to the same build configuration as the profile target and this has tripped me up more than a time or two.
那应该这样做。请注意,无论出于何种原因,构建目标未设置为与配置文件目标相同的构建配置,这让我绊倒了一两次。
回答by leo
Try selecting a different code signing identity, i.e. provisioning profile, for the Releaseconfiguration.
尝试为发布配置选择不同的代码签名标识,即配置文件。
回答by Dan
I found out what the issue was, as I had the exact same problem.
我发现了问题所在,因为我遇到了完全相同的问题。
The answer comes from: Missing symbol names when profiling IPhone application with Instruments
答案来自:使用 Instruments 分析 iPhone 应用程序时缺少符号名称
- Ensure that you have compiled your code with debug flags enabled (e.g.
-g3
). - Execute
dsymutil
on your binary/dynamic library that you want to be able to access the debug information for.
- 确保您已在启用调试标志的情况下编译代码(例如
-g3
)。 dsymutil
在您希望能够访问其调试信息的二进制/动态库上执行。
This generates a dSYM bundle folder, and when indexed by Spotlight the debug information necessary is made available to Instruments.
这会生成一个 dSYM 包文件夹,当被 Spotlight 索引时,必要的调试信息将提供给 Instruments。
I suppose in your case, it took some time before Spotlight had things indexed - and when it had, then things magicallyworked out.
我想在你的情况下,Spotlight 需要一些时间才能将事情编入索引 - 当它被编入索引时,事情就神奇地解决了。
回答by Shepmaster
In newer versions of Instruments (I have 5.1.1 (55045)
), you can add additional paths to be searched for the dSYMs and source code
在较新版本的 Instruments(我有5.1.1 (55045)
)中,您可以添加要搜索 dSYM 和源代码的其他路径
Open up Instruments' Preferences, then click the "dSYMs And Paths" tab.
打开仪器的首选项,然后单击“dSYM 和路径”选项卡。
Then add your path to the list.
然后将您的路径添加到列表中。
回答by Marcelo Cantos
It just started working; no rhyme or reason.
它刚刚开始工作;没有韵律或理由。
I have spent the last half-hour trying to get it to fail again, in the hope of providing a more useful answer here, but I can't, even after recreating the skeleton OpenGL program from scratch, retracing all of my steps.
我花了最后半个小时试图让它再次失败,希望在这里提供一个更有用的答案,但我不能,即使在从头开始重新创建骨架 OpenGL 程序之后,我也不能回溯我的所有步骤。
I did open the symbolicatecrash script in emacs (It has been implicated elsewhere, wrt this kind of problem), and it started working after I did this. But at no point did I change or save it.
我确实在 emacs 中打开了symbolicatecrash 脚本(它已经被牵连到其他地方,出现了这种问题),并且在我这样做后它开始工作。但我从未更改或保存过它。
It's a mystery.
这是一个谜。
回答by Mecki
One reason for instruments having no symbols could be that Spotlight cannot find the dSYM file. So your change from DWARF with dSYM
to DWARF
is not a good idea. You should change it back since without a dSYM file, you won't get symbols anyway (at least this seems to be the case for Snow Leopard, I have seen reports that some people also got symbols without dSYM files, however, all those people were using Lion). After making the change, make sure you create a clean build (sometimes Xcode fails to generate the dSYM file on my system for non-clean builds).
仪器没有符号的原因之一可能是 Spotlight 找不到 dSYM 文件。所以你从DWARF with dSYM
到的改变DWARF
不是一个好主意。你应该把它改回来,因为没有 dSYM 文件,你无论如何都不会得到符号(至少雪豹似乎是这种情况,我看到有报道说有些人也得到了没有 dSYM 文件的符号,但是,所有这些人正在使用狮子)。进行更改后,请确保您创建了一个干净的构建(有时 Xcode 无法在我的系统上为非干净构建生成 dSYM 文件)。
If you still get no symbols after all that, something is wrong with your Spotlight database. Try adding the folder that contains the dSYM files after a build to the list of folders Spotlight shall not index and then remove it again from that list. This causes Spotlight to reindex the files.
如果您仍然没有得到任何符号,那么您的 Spotlight 数据库有问题。尝试将构建后包含 dSYM 文件的文件夹添加到 Spotlight 不应索引的文件夹列表中,然后再次从该列表中将其删除。这会导致 Spotlight 重新索引文件。
If this also doesn't help, maybe your Spotlight index is completely corrupted. In that case, try the following on a Terminal:
如果这也没有帮助,则可能您的 Spotlight 索引已完全损坏。在这种情况下,请在终端上尝试以下操作:
sudo mdutil -i off /
sudo mdutil -E /
sudo mdutil -i on /
This causes Spotlight to first stop indexing your main hard drive, then delete all index data collected in the past and then start reindexing it. The lines above assume that your dSYM files are located on the main hard drive (and not on any other hard drive or network volume, otherwise you must replace '/' with the appropriate mount point of that volume). Give Spotlight some time to reindex before you try again.
这会导致 Spotlight 首先停止索引您的主硬盘驱动器,然后删除过去收集的所有索引数据,然后开始重新索引它。上面几行假设您的 dSYM 文件位于主硬盘驱动器上(而不是任何其他硬盘驱动器或网络卷上,否则您必须用该卷的适当安装点替换“/”)。在再次尝试之前,请给 Spotlight 一些时间来重新编制索引。
回答by Logicsaurus Rex
Here's my environment...
这是我的环境...
- XCode 8.2
- Mac OS v10.12 Sierra
- 代码 8.2
- Mac OS v10.12 Sierra
I had the same problem running in the simulator, and it was driving me nuts because ALL the standard go-to fixes were not working.
我在模拟器中运行时遇到了同样的问题,这让我发疯,因为所有标准的修复都不起作用。
What did it for me was plugging my iPad into the MacBook and running an instruments session against said app on my plugged in iPad. Instruments properly symbolicated my app when running on the iPad, and then continued to work when I disconnected the iPad and ran instruments later in the simulator.
它对我的作用是将我的 iPad 插入 MacBook 并在我插入的 iPad 上针对所述应用程序运行仪器会话。在 iPad 上运行时,Instruments 正确地象征了我的应用程序,然后当我断开 iPad 连接并稍后在模拟器中运行仪器时继续工作。
I suspect it had something to do with updating my project to use the following...
我怀疑这与更新我的项目以使用以下内容有关...
- libsqlite3.tbd instead of libsqlite3.dylib
- libstdc++.6.tbd instead of libstdc++.dylib
- libsqlite3.tbd 代替 libsqlite3.dylib
- libstdc++.6.tbd 代替 libstdc++.dylib
I don't know why that would be the case, but that was the ONLY project change I had made before my symbols were lost in Instruments.
我不知道为什么会这样,但这是我在我的符号在 Instruments 中丢失之前所做的唯一项目更改。