Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

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

like image 942
gary Avatar asked Jan 05 '10 20:01

gary


People also ask

How do I debug in Xcode step by step?

When you run an application in Xcode, the debugger is automatically started and attached to the process of the application. Click the Run button in the top left or press Command + R. From the moment the application is up and running, we can start inspecting the process and, if necessary, debug it.

What is LLDB in Xcode?

LLDB is a debugging component used in the LLVM project which was developed by the LLVM developer group. Xcode uses the LLDB as the default debugging tool. The full form of LLDB is Low-level debugger. Breakpoints help a developer to stop the execution of the program at any point.

How do I track variables in Xcode?

Right click in the local variables window to see the "Watch Expression" menu command. Type the variable name and the variable will be added.

How do you set breakpoints in Xcode?

Navigate to a line in your code where you want execution to pause, then click the gutter or line number in the source editor to set a breakpoint. Xcode displays a breakpoint icon to indicate the location. Drag a breakpoint up or down to move it to another location; drag it away from the gutter to remove it.


1 Answers

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.

See the attached screenshot highlighted with a red oval.

screenshot

like image 166
Max MacLeod Avatar answered Sep 27 '22 19:09

Max MacLeod