C++ Crash Course: a fast-Paced Introduction



Yüklə 7 Mb.
Pdf görüntüsü
səhifə58/71
tarix20.09.2023
ölçüsü7 Mb.
#145939
1   ...   54   55   56   57   58   59   60   61   ...   71
C Crash Course A Fast-Paced Introduction by Josh Lospinoso

Debug
4
Breakpoints
4
Add 
Breakpoint at Current Line
. A breakpoint appears, as shown in 
Figure 1-7.


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/.

Yüklə 7 Mb.

Dostları ilə paylaş:
1   ...   54   55   56   57   58   59   60   61   ...   71




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin