Summary of IDEA debugging (set breakpoints for debugging) (black background version:)

Premise: Compile the program to be debugged first.
1. Set a breakpoint


Select the line of code to set a breakpoint, and click the left mouse button behind the area of ​​the line number.

2. Start a debug session

Click the little bug pointed by the red arrow to start debugging.


The Debug view appears below the IDE, and the red arrow points to the line of code where the debugger stays. In the method f1(), line 9 of the program. The area where the red arrow hovers is the method call stack area of ​​the program. In this area, the methods used by the program execution to the breakpoint are displayed. The lower the method is called, the earlier it will be called.

3. Single step debugging
3.1 step over


Click the button pointed by the red arrow, and the program executes one line down (if there is a method call in the current line, this method will be executed and returned, and then go to the next line)

3.2 step into

Click the button pointed by the red arrow, and the program will execute one line down. If the line has a custom method, run into the custom method (the method that will not enter the official class library).

Specific steps are as follows:


A. Set a breakpoint at the custom method f1() and execute debugging

B. Click:

can be seen:

3.3 Force step into


This button can step into any method while debugging.

3.4 step out

If you enter a method (such as f2()) during debugging and feel that there is no problem with the method, you can use stepout to jump out of the method and return to the next line where the method is called. It is worth noting that this method has already executed.

3.5 Drop frame

After clicking this button, you will return to the calling place of the current method (as shown in the figure above, the program will return to main()) to re-execute, and the values ​​of all context variables will also return to that time. As long as there are superior methods in the call chain, you can jump to any one of them.

4. Advanced debugging

4.1 Debugging across breakpoints

Set multiple breakpoints:

Turn on debugging:

To move to the next breakpoint, click as shown below:

The program will run the code that needs to be executed between one breakpoint and the next breakpoint; if there is no breakpoint in the following code, clicking the button again will execute the program.

4.2 View breakpoints

Click the button pointed by the arrow to view the breakpoints you have set and set some properties of the breakpoints.

Arrow 1 points to the breakpoint you have set, and arrow 2 can set a conditional breakpoint (when a certain condition is met, the execution of the program is suspended, such as c==97).

After finishing debugging, the set breakpoint should be deleted at arrow 1 (after selecting the breakpoint to be deleted, click the red minus sign above).

Thanks: Hongyan Zangfeng : https://www.cnblogs.com/yjd_hycf_space/p/7483471.html

 

Guess you like

Origin blog.csdn.net/lee_x_lee/article/details/105881053