The debugging interface of Xcode


We can add a breakpoint to a line by simply clicking on its left.

We can disable a breakpoint by clicking on it and we can enable it back by clicking back on it. Disabled breakpoints are ignored by the debugger.

To delete a breakpoint, we must right-click on it and click on the item Delete Breakpoint.

Starting the debugger

When we run a program inside Xcode, it is, by default, automatically launched with the debugger.

If there are breakpoints, the debugger will automatically stop when they are reached.

By placing the cursor on the name of a variable, we can see its current value.

The following buttons, appearing when the debugger is stopped, are used to control it:

The first button makes the debugger continue. The second one makes it execute the next line of code. The third one makes it step into the function and the last one makes it step out the current function.

The function call stack

At the left of the window, by clicking on the button with the spray bottle icon, we can display debugging information, the function call stack included.

The reason the call stack is grouped under Thread 1 is that, as we will see later, it is possible to use multiple threads to execute many instructions at the same time (in parallel) and each of them have its own call stack. By default, only one thread is used.