<>C Single step trace debugging in language

<> Single step debugging refers to the process of program development , In order to find the program bug, A commonly used debugging method , Follow the process of program execution step by step , According to the value of the variable , Find the cause of the error .

Let's take a simple applet as an example , The procedure here must be under the project , A single file cannot be debugged , It will be compiled and executed directly .
The program uses functions max() The implementation finds the larger of the two variables , For simplicity ,a,b All values are given .
#include <stdio.h> int max(int x,int y) { int temp; temp = x>y?x:y;
/* Judge formal parameters x and y Size of , And assigned to temp, Then the function body is brought out */ return temp; } int main() { int a,b,result; a=
3; b=4; result = max(a,b); /* Will record a Variable of original value temp, Assign to b, realization a towards b transformation */ printf(
"%d\n",result); return 0; }
<>1. Here is the beginning of the program main() Line sequence number in function 11 There, the single mouse hit a breakpoint , Single step debugging

<>2. Click the button with a bug below , Choose the one inside watches, You can enter the change of the variable value to be checked , Why is it called a bug here , You can also check the story .

Select the one inside watches, You can enter the variable name manually , For display , I entered it here a,b,temp also result, Let's look at what happened during debugging .

<>3. Click the red triangle here to start debugging ( A black box will pop up here , Leave it alone )


At this time, note that all variables defined before are watches There are some values in the small window , These values are old values , Has not been updated in this program . At the same time, there is a small yellow logo in the program , Used to display where the current program has been executed .

<>
4. Here are some common function keys :① Is used to start debugging ;② Is used for line by line execution , That is, the small yellow logo will run to the next line ;③ Is used to enter the function body , If you execute directly line by line, you will not enter other functions ;④ and ③ contrary , Exit from function body , go back to main Function continues . If you are interested in other buttons, you can check the information , Not here ,① The one next to it will be used in multi line debugging .

<>5. Next, click button 2 to debug line by line , Observe the change of variable value , When executed to result = max(a,b); Here when , Can see a,b The value of has been displayed

<>
6. Next, click button 3 , Enter into max Look inside the function , With in max Single step debugging in function , Finally, it can be found that temp Finally, set the maximum value :4, Successfully brought out the function body and sent it to main Functionally result variable .

<>7. Finally, execute the print statement , You can see the output display in the black box 4 Yes .

Generally, there are no errors when compiling the program , As a result, unexpected problems occurred in the implementation , You can use the debugger at this time , Find out where the problem is with the program . It is also a very important programming skill to debug the program and find the error !

Technology
©2019-2020 Toolsou All rights reserved,
【C++ Must see for entry 】C++ from 0 reach 1 Introductory programming axios Interceptor packaging and use Spring Boot Interview must ask : Automatic configuration principle VMware 16 install centos 7 Detailed tutorial C Language data structure - Sequence table delete duplicates V2.0.0 The 12th Blue Bridge Cup c++b Group personal problem solving On sending data from serial port single chip microcomputer to upper computer centos7 install RabbitMqjava Polymorphic array of opencv-python Fourier transform and inverse transform