24
Chapter 1
Figure 1-7: Inserting a breakpoint
3. Select
Run
. The program will run up to the line with the inserted
breakpoint. The debugger
will halt program execution, and a green
arrow will appear to indicate the next instruction to be run,
as shown
in Figure 1-8.
Figure 1-8: The debugger halts execution at the breakpoint.
4. Select
Debug
4
Step Over
to execute the instruction without “stepping
into” any function calls. By default, the
keyboard shortcut for step
over is F6.
5. Because the next line calls
step_function
, select
Debug
4
Step Into
to
call
step_function
and break on the first line.
You can continue debug-
ging this function by stepping into/over its instructions. By default, the
keyboard shortcut for step into is F7.
Up and Running
25
6. To allow
execution to return to
main
, select
Debug
4
Step Out
. By
default, the keyboard shortcut for step out is F8.
7. Inspect the Autos window at the bottom of the
main.cpp screen. You can
see the current value of some
of the important variables, as shown in
Figure 1-9.
Figure 1-9: The Autos window shows the values of variables at the current breakpoint.
You can see
num1
is set to 42 and
result1
is set to 1. Why does
num2
have a gibberish value? Because the initialization to 0 hasn’t
happened
yet: it’s the next instruction to execute.
The Xcode debugger supports many more features. For more informa-
tion, check out the Xcode documentation link at
https://ccc.codes/.
Dostları ilə paylaş: