Xcode Debugger - 如何在 CPU 指令级别单步执行

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

Xcode Debugger - how to single step at level of CPU instructions

xcodedebugging

提问by gary

This is definitely obsessive, but I am fascinated by how cleverly the compiler translates C code into machine instructions. Since I am a little fuzzy on some instructions, it would be helpful if I could watch the operation of a compiled program at the level of individual machine instructions - "below" the level of a C statement (which might generate several CPU instructions). In other words, can I watch the registers/memory change after a single machine instruction?

这绝对令人着迷,但我对编译器将 C 代码转换为机器指令的巧妙程度感到着迷。由于我对某些指令有点模糊,如果我能在单个机器指令级别(“低于”C 语句级别(可能会生成多个 CPU 指令)级别)观察编译程序的操作会很有帮助。换句话说,我可以在单条机器指令后观察寄存器/内存变化吗?

I'm sure it's possible with some other debuggers, but I am only using Xcode.

我确定其他一些调试器也可以,但我只使用 Xcode。

采纳答案by Dave DeLong

siis "Step Instruction", and niis "Next Instruction". They have the same semantics as "step" and "next" do for lines of code, just on the instruction level.

si是“步骤指令”,ni是“下一步指令”。它们与代码行的“step”和“next”具有相同的语义,只是在指令级别。

回答by Max MacLeod

It's possible to use Xcode's step over, step in, and step out commands with the debugger. The trick is to hold the ctrl(Control)key while you mouse over the debugger step icons to change the context. Underneath each step icon, the line will change to a dot and you can then step at the instruction level.

可以在调试器中使用 Xcode 的 step over、step in 和 step out 命令。诀窍是在将鼠标悬停在调试器步骤图标上时按住ctrl(Control)键以更改上下文。在每个步骤图标下方,线条将变为一个点,然后您可以在指令级别执行步骤。

See the attached screenshot highlighted with a red oval.

请参阅以红色椭圆突出显示的附加屏幕截图。

screenshot

截屏

回答by Seva Alekseyev

In the Debugger window, enable assembly: Run/Debugger display/Source and disassembly. Wait till you hit a breakpoint. Then use Run/Step into(over) instruction to step in assembly.

在调试器窗口中,启用程序集:运行/调试器显示/源代码和反汇编。等到你遇到断点。然后使用 Run/Step into(over) 指令单步执行汇编。

回答by gary

Ooops, didn't check closely enough - Step Into w/Option (Cmd-Opt-Shft-I = ???I)

哎呀,没有仔细检查 - Step Into w/Option (Cmd-Opt-Shft-I = ???I)