Xcode Debugger:为什么只显示汇编程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1421093/
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 Debugger: Why is it only showing me assembler?
提问by Breton
I'm just starting out with Cocoa development in Xcode, doing the hello world example. I'm up to step 6 of the section "runtime debugging", which is
我刚开始在 Xcode 中进行 Cocoa 开发,做 hello world 示例。我已经到了“运行时调试”部分的第 6 步,即
Using the Step Over button in the debugger toolbar, begin stepping through the code. As each line of code executes, you can examine the program's state. The value of a variable is sometimes drawn in red to indicate that the value was modified in the last step. Notice that the debugger pauses before executing the indicated line. After each pause, you can add additional breakpoints or choose Debug > Restart to terminate the application and start a new debugging session.
使用调试器工具栏中的 Step Over 按钮,开始单步调试代码。在执行每一行代码时,您可以检查程序的状态。变量的值有时用红色绘制,表示该值在最后一步中被修改。请注意,调试器在执行指定的行之前暂停。每次暂停后,您可以添加额外的断点或选择 Debug > Restart 以终止应用程序并启动新的调试会话。
now what I've been pulling my hair out for over the last hour is the fact that this debugger will only show me assembly code. I can manually select my source code file, but as soon as I click "Step over" I'm right back in assembler view. I can't for the life of me figure out how to turn the assembler off, and make it show me my source code!
现在我在过去一个小时里一直在纠结的是这个调试器只会向我显示汇编代码。我可以手动选择我的源代码文件,但是一旦我单击“Step over”,我就会立即回到汇编程序视图中。我一生都无法弄清楚如何关闭汇编器,并让它向我展示我的源代码!
回答by Mike Fahy
I know this article is a hundred years old, but in case anyone is wondering how to address this issue in more recent Xcode versions (as opposed to Xcode 3), you'll find the appropriate setting labeled Always Show Disassemblyunder Debug>Debug Workflowin Xcode 6 and up. Ensure the option is NOTchecked.
我知道这篇文章已经有一百年历史了,但是如果有人想知道如何在更新的 Xcode 版本(而不是 Xcode 3)中解决这个问题,您会在Debug>Debug Workflow下找到标记为Always Show Disassembly的适当设置在 Xcode 6 及更高版本中。确保选项不选中。
In Xcode 5, the option was labeled Show Disassembly When Debuggingunder Debug>Debug Workflow. Ensure that "Show Disassembly When Debugging" is unchecked.
在 Xcode 5 中,该选项在Debug>Debug Workflow下标记为Show Disassembly When Debugging。确保未选中“调试时显示反汇编”。
Back in Xcode 4, the Show Disassembly When Debuggingsetting was found under Product>Debug Workflow. Again, ensure that the option remains unchecked.
回到 Xcode 4,在Product>Debug Workflow下找到Show Disassembly When Debugging设置。再次确保该选项保持未选中状态。
This was driving me crazy, too.
这也让我发疯。
NOTE: The information above is still valid for Xcode 11+. I've applied updates to this answer as new versions of Xcode have been released. Fortunately, the option has remained unchanged since Xcode 6 (so far).
注意:以上信息对 Xcode 11+ 仍然有效。随着新版本的 Xcode 的发布,我已经对此答案进行了更新。幸运的是,该选项自 Xcode 6(到目前为止)以来一直保持不变。
回答by Peter Hosey
There are two other things to make sure of:
还有两件事需要确保:
- That you're looking at one of your own functions/methods. If the stack frame you're looking at is a function or method from one of the frameworks, you're going to see assembly no matter how you have Xcode configured.
- That you are running a Debug build. Strip debug symbols (as in a Release build), and you'll be looking at assembly even for your own code, no matter what.
- 您正在查看自己的功能/方法之一。如果您正在查看的堆栈框架是来自其中一个框架的函数或方法,那么无论您如何配置 Xcode,您都会看到程序集。
- 您正在运行调试版本。剥离调试符号(如在发布版本中),无论如何,您甚至会为自己的代码查看汇编。
回答by Breton
I actually figured this out before I posted, but I wanted to save others potential future headaches, (and also in case I forget later) as I could not find the answer to this by searching stack overflow, but I did find that I'm not alone.
我实际上在我发布之前就想到了这一点,但我想避免其他人未来可能会遇到的麻烦(以及以防我以后忘记),因为我无法通过搜索堆栈溢出找到答案,但我确实发现我是不是一个人。
From the run menu, select "Debugger Display" > "Source Only", or "Debugger Display" > "Source and Disassembly"
从运行菜单中,选择“调试器显示”>“仅源代码”,或“调试器显示”>“源代码和反汇编”