简体   繁体   English

Xcode调试器-通过方法调试

[英]Xcode debugger - debug through methods

I'm used to using Visual Studio's debugger which will essentially track the logic path through the application, jumping from method to method allowing you to see how something might not be working. 我习惯于使用Visual Studio的调试器,该调试器本质上将跟踪应用程序中的逻辑路径,从一个方法跳转到另一个方法,使您可以查看某些东西可能不起作用。

When I'm debugging in Xcode (4.6.3) using 'Step into' or 'step over' as needs be I go through some methods but then it seems to jump into compiled code and I'm lost. 当我在Xcode(4.6.3)中使用'Step into'或'step over'进行调试时,我会通过一些方法,但是似乎跳入了已编译的代码,我迷路了。 I can't see the logic flow or order of events due to this so is there something I'm doing wrong? 由于这个原因,我看不到逻辑流程或事件顺序,所以我做错了什么吗?

How can I track what's actually being done in the code but in a way that makes sense and doesn't show me compiled code? 如何跟踪代码中实际完成的工作,但以一种有意义且不会向我显示已编译代码的方式进行呢?

For instance I put a breakpoint on ViewDidLoad as I want to see what happens after that method is called because my app isn't working as expected. 例如,我在ViewDidLoad上设置了一个断点,因为我想查看调用该方法后发生的情况,因为我的应用无法正常工作。 Break points elsewhere aren't getting hit so there's a problem which I need to track down. 其他地方的断点没有受到影响,所以有一个问题需要我追踪。

So my ViewDidLoad breakpoint is hit, I work my way through that method and then when the debugger hits the end of the method it flies off into compiled code so I don't know what's next in the order of events. 因此,我的ViewDidLoad断点被击中,我按顺序遍历该方法,然后当调试器击中该方法的末尾时,它会飞入已编译的代码中,因此我不知道事件的顺序。

I don't think you can avoid this issue, given the code it "flies off" to likely has no symbols and anyway you don't have the source. 我认为您无法避免这个问题,因为它“飞走”的代码很可能没有符号,而且无论如何您都没有源代码。

This situation is not unique to Xcode; 这种情况不是Xcode独有的。 it will happen with Visual Studio and every other O/S. 这将在Visual Studio和其他所有O / S中发生。

One approach is to provide all the subclassed methods of the view/whatever (even if all they do is call the [super method] and nothing more) and set breakpoints on each of them. 一种方法是提供视图/所有视图的所有子类化方法(即使它们所做的只是调用[super method] ,仅此而已),并在每个方法上设置断点。

Alternatively if instance variables are getting whacked in unexpected ways, set a watchpoint . 或者,如果实例变量以意想不到的方式受到攻击,请设置观察点

I was facing the exact same situation. 我正面临着完全相同的情况。 However, the below two links helped me understand why it was happening. 但是,下面的两个链接帮助我了解了为什么会这样。

Basically, you first need to " UN-CHECK " the option in DEBUG->DEBUG WORKFLOW->SHOW DISASSEMBLY WHEN DEBUGGING . 基本上,您首先需要在DEBUG-> DEBUG WORKFLOW-> SHOW DISASSEMBLY时取消 检查 ”该选项。

Then, If you're trying to debug your own code, then debugging works the same way as in Visual Studio. 然后,如果您要调试自己的代码,则调试的工作方式与在Visual Studio中相同。 But if the code that you're looking is being called from some Framework, then the debugger will surely go back to assembly code no matter what the setting of "Show Disassembly" is. 但是,如果您正在从某些Framework中调用您要查找的代码,则无论“ Show Disassembly”设置如何,调试器都一定会返回到汇编代码。

Check these links for further clarity. 检查这些链接以进一步明确。 They are answers from the same page. 它们是同一页面上的答案。

XCode Debugger: Why is it only showing me assembler? XCode Debugger:为什么只向我显示汇编程序?
https://stackoverflow.com/a/1421275/2377928 https://stackoverflow.com/a/1421275/2377928
https://stackoverflow.com/a/7301489/2377928 https://stackoverflow.com/a/7301489/2377928

Thanks, 谢谢,

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM