C++ Crash Course: a fast-Paced Introduction


Debug 4 Start Debugging



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

Debug
4
Start Debugging
. The program will run up to the line 
where you’ve inserted a breakpoint. The debugger will halt program 
execution, and a yellow arrow will appear to indicate the next instruc-
tion to be run, as shown in Figure 1-5.
Figure 1-5: The debugger halts execution at the breakpoint.
4. Select 
Debug
4
Step Over
. The step over operation executes the 
instruction without “stepping into” any function calls. By default
the keyboard shortcut for step over is F10.


Up and Running
23
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 F11.
6. To allow execution to return to 
main
, select 
Debug
4
Step Out
. By 
default, the keyboard shortcut for this operation is
shift
-F11.
7. Inspect the Autos window by selecting 
Debug
4
Windows
4
Auto
. You 
can see the current value of some of the important variables, as shown 
in Figure 1-6.
Figure 1-6: 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.
N O T E
 
The debugger has just emphasized a very important low-level detail: allocating an 
object’s storage and initializing an object’s value are two distinct steps. You’ll learn 
more about storage allocation and object initialization in Chapter 4.
The Visual Studio debugger supports many more features. For more 
information, check out the Visual Studio documentation link available at 
https://ccc.codes/.
Xcode
Xcode also has an excellent, built-in debugger that’s completely integrated 
into the IDE.
1. Open main.cpp and locate the first line of 
main
.
2. Click the first line and then select 

Yüklə 7 Mb.

Dostları ilə paylaş:
1   ...   53   54   55   56   57   58   59   60   ...   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