开发者

Setting a breakpoint in Xcode causes cursor to go to random line

Whenever i set a breakpoint in Xcode, using the gutter, my cursor jumps to a random line of code, typically, 10-20 lines above the breakpoint. Why is it doing th开发者_如何学运维is? It is very annoying... Thanks.


This typically happens when you turn on various optimizations in your debug build. Debug builds should have no optimization. I have a list of possible causes here. They reduce to making sure:

  • "Strip Debug Symbols During Copy" is unchecked.

  • "Generate Debug Symbols" is checked.

  • "Optimization Level" is set to "None [-O0]".

  • "Use Separate Strip" is unchecked.

  • "Additional Strip Flags" has nothing set (I don’t think this matters if strip isn't run).

  • "Unroll Loops" is unchecked

  • None of the individual files have optimization-related (like -funroll_loops) flags attached.

More detail is provided in my post.


AFAIK it's jumping cause of compiler optimizations (cursor position follows relative code instruction) in binary. Try building your project without optimizations and try debugging again.

Since i'm not a guru at this yet. I may be wrong.


I tried the debugger configuration mentioned above and still get the jumping effect. What I have found works is opening up all my collapsed code (methods, code blocks, and comment blocks) and the problem of the jumping cursor on setting breakpoints goes away. The shortcut to open collapsed code is ctrl + cmd + down arrow. Unfortunately, the comment blocks you have to do one at a time. I think this is a pain and almost would rather just deal with the jumping of the breakpoints than opening up my collapsed code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜