Xcode 3.2 + LLVM = 调试时没有本地符号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1370945/
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 3.2 + LLVM = no local symbols when debugging
提问by glebd
I have a project for Mac OS X 10.5 that I'm building on 10.6 using Xcode 3.2. When I use GCC 4.2 for Debug build and hit a breakpoint, Xcode debugger displays local variable information normally. If I choose LLVM GCC 4.2 or Clang LLVM, when I hit breakpoint, local symbols are not available, and GDB says No symbol 'self' in current contextif I try to print selfor any other local symbol. In all cases Generate debug infooption is set. The Debug configuration is set to $(NATIVE_ARCH)
and 10.5 SDK, Build active architecture onlyoption is set. When GDB starts, I can see it is being configured as x86_64-apple-darwin. I must be missing something obvious. How do I make GDB show local symbols when using a LLVM compiler?
我有一个 Mac OS X 10.5 项目,我使用 Xcode 3.2 在 10.6 上构建。当我使用 GCC 4.2 进行调试构建并遇到断点时,Xcode 调试器正常显示局部变量信息。如果我选择 LLVM GCC 4.2 或 Clang LLVM,当我遇到断点时,本地符号不可用,并且如果我尝试打印self或任何其他本地符号,GDB在当前上下文中会显示 No symbol 'self'。在所有情况下,都设置了Generate debug info选项。Debug 配置设置为10.5 SDK,设置仅构建活动架构选项。当 GDB 启动时,我可以看到它被配置为 x86_64-apple-darwin。我一定遗漏了一些明显的东西。使用 LLVM 编译器时如何让 GDB 显示本地符号?$(NATIVE_ARCH)
采纳答案by Clay Bridges
For those not familiar, a little more detail to cdespinosa's answer, which worked for me, and which I voted up.
对于那些不熟悉的人,请详细了解 cdespinosa 的答案,这对我有用,并且我投了赞成票。
- From the Xcode menu, select Project > Edit Project Settings...
- Choose the Build tab
- In the search box type "Optimization Level", choose that field, and select None.
- Next search for "Debug Information Format", choose that field, and select "DWARF" or "DWARF with dSYM".
- 从 Xcode 菜单中,选择项目 > 编辑项目设置...
- 选择构建选项卡
- 在搜索框中键入“优化级别”,选择该字段,然后选择“无”。
- 接下来搜索“调试信息格式”,选择该字段,然后选择“DWARF”或“DWARF with dSYM”。
Would have put this in comments to his post if I had the privs. ;)
如果我有权限,我会把这个放在他的帖子的评论中。;)
This cost me some serious time, and was frankly kind of sloppy on Apple's part, but in general I can't complain.
这花了我一些时间,坦率地说,Apple 有点草率,但总的来说,我不能抱怨。
回答by cdespinosa
Make sure you're building with Dwarf symbols and no optimization. llvm is a new back-end, and not all of its optimized codegen is hooked up to debug symbol generation yet.
确保您使用 Dwarf 符号进行构建并且没有进行优化。llvm 是一个新的后端,并不是所有优化的代码生成都连接到调试符号生成。
回答by dodgio
This may help. Try turning off "Link-Time Optimization" in the project's build options. That fixed a problem I had with missing debug symbols.
这可能会有所帮助。尝试关闭项目构建选项中的“链接时间优化”。这解决了我缺少调试符号的问题。
In fact, that fixed a bunch of weird problems I was having with Clang. I'd say that feature is just too bleeding edge to use yet.
事实上,这解决了我在使用 Clang 时遇到的一堆奇怪的问题。我想说这个功能太先进了,无法使用。
回答by Employed Russian
GDB from FSF only added support for JIT code very recently.
FSF 的 GDB最近才添加了对 JIT 代码的支持。
I don't know whether Apple-supplied GDB has support for it at all (do you get reasonable stack traces?). If it does, this support is (apparently) incomplete.
我不知道 Apple 提供的 GDB 是否完全支持它(您是否获得了合理的堆栈跟踪?)。如果是这样,这种支持(显然)是不完整的。
回答by SpaceMonkey
I was having this problem and solved it by putting a tick next to the menu item: "Project > Set Active Build Configuration > Debug". Previously, the "Release" option was selected. Locals started showing up in the debugger for my project from then on.
我遇到了这个问题并通过在菜单项旁边打勾解决了它:“项目>设置活动构建配置>调试”。以前,选择了“发布”选项。从那时起,本地人开始出现在我的项目的调试器中。