XCode 4 Step into 不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5641957/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 20:48:46  来源:igfitidea点击:

XCode 4 Step into doesn't work

xcode

提问by Bibhas BHATTACHARYA

Im using XCode 4 and seeing a problem with debugging that did not exist in 3.x.

我正在使用 XCode 4 并看到 3.x 中不存在的调试问题。

I am putting a breakpoint at a line where I call an object method.

我在调用对象方法的行上放置了一个断点。

Product *p = [[Product alloc] init]; 
[p  print];  <-- Put a breakpoint here

After control stops at that line, I try to step into the method (F7). But nothing happens. System just skips over the line and goes to the next line (same behavior as Step Over).

控制在该行停止后,我尝试进入该方法 (F7)。但什么也没有发生。系统只是跳过该行并转到下一行(与 Step Over 相同的行为)。

Step into works fine for plain C language projects. The problem is with Objective-C methods. How do I fix this problem? Thanks.

对于普通的 C 语言项目来说,Step into 工作正常。问题在于 Objective-C 方法。我该如何解决这个问题?谢谢。

回答by Sam DiBattista

Not sure if this will help -- Go into system preferences, and under the Keyboard general settings ensure that the "Use all F1 F2 etc. as standard function keys" option is checked.

不确定这是否有帮助 - 进入系统首选项,并在键盘常规设置下确保选中“使用所有 F1 F2 等作为标准功能键”选项。

F7 started to work for me after I checked that.

在我检查后,F7 开始对我来说有效。

Hope that helps...

希望有帮助...

回答by stephen

Check that the instance is not nil before trying to step into it's instance method. As embarrassing as it may seem, we all do it occasionally.

在尝试进入它的实例方法之前,请检查该实例是否不为零。尽管看起来很尴尬,但我们偶尔都会这样做。

回答by ipmcc

Stepping into ObjC method calls is not always possible. The way it was explained to me, there are internal runtime data structures that must be in a consistent state in order to reliably step into an ObjC method. If those internals happen to be in an inconsistent state when the program stops at your breakpoint, stepping in in the debugger will fail, and it will step over the call instead. This was also true in Xcode 3, and really has little or nothing to do with Xcode, but is an ObjC runtime and debugger issue. I estimate anecdotally (working in Xcode full-time for 3+ years) that stepping into an ObjC method call fails ~5% of the time. I find that it happens most often when it will be the most inconvenient to me. :)

单步执行 ObjC 方法调用并不总是可能的。向我解释的方式是,内部运行时数据结构必须处于一致状态才能可靠地进入 ObjC 方法。如果程序在您的断点处停止时这些内部结构碰巧处于不一致状态,则单步调试器将失败,而它将单步执行调用。这在 Xcode 3 中也是如此,并且与 Xcode 几乎没有或根本没有关系,而是 ObjC 运行时和调试器的问题。我估计(在 Xcode 中全职工作 3 年以上),我估计进入 ObjC 方法调用失败的概率约为 5%。我发现它最常发生在对我来说最不方便的时候。:)

That said, if you're NEVER able to step into ANY ObjC method call, then there's likely another problem, as I've been able to step into ObjC method calls many times with Xcode 4, and don't see this problem any more or less often than I did with Xcode 3.

也就是说,如果您永远无法进入任何 ObjC 方法调用,那么可能还有另一个问题,因为我已经能够使用 Xcode 4 多次进入 ObjC 方法调用,并且不再看到这个问题或者比我使用 Xcode 3 时更少。

回答by JasonYang

fn+f7 always works for me. Although step into in Obj-C is kinda weird from time to time. You'd better set more breakpoints if you know where the code is heading.

fn+f7 总是对我有用。虽然时不时进入 Obj-C 有点奇怪。如果你知道代码的走向,你最好设置更多的断点。

回答by Alexander Staubo

Switching to the gdb debugger works for me. Go to Edit Schemes, the Info tab for the Run phase, change from LLDB to GDB.

切换到 gdb 调试器对我有用。转到 Edit Schemes,Run 阶段的 Info 选项卡,从 LLDB 更改为 GDB。

It's still not perfect. In particular it seems you have to use "Step into instruction" (with the appropriate key, or holding ctrl while hitting the step button) a lot if nothing happens, and to see registers and so on you have to use the gdb command line within the Xcode windows.

它仍然不完美。特别是,如果没有任何反应,您似乎必须经常使用“步入指令”(使用适当的键,或按住 ctrl 并按步骤按钮),并且要查看寄存器等,您必须在其中使用 gdb 命令行Xcode 窗口。

回答by Amir Latif

I don't know enough about OSX to understand why this is fubar but I just tried changing the default key bindings to f13-f17 for all the usual bindings of pause/continue, step into/out of etc. Works for me. Pretty sucky QA on the XCode4 team possibly?

我对 OSX 的了解不够,无法理解为什么这是 fubar,但我只是尝试将默认键绑定更改为 f13-f17,用于所有常见的暂停/继续、步入/退出等绑定。对我有用。XCode4 团队的 QA 可能很糟糕?

回答by Dojo

Remove the particular file and add the file again. This fixes my problem.

删除特定文件并再次添加该文件。这解决了我的问题。