当前位置:网站首页>Learn to use the idea breakpoint debugging tool
Learn to use the idea breakpoint debugging tool
2022-07-03 04:46:00 【Program Xiaoxu】
IDEA Breakpoint debugging
In the process of breakpoint debugging, it is always running , After setting a breakpoint on a line, it will stop here . So as to find the problem . Be commonly called Debug
Breakpoint debugging shortcut
- F7( Jump into method )
- F8( skip — Step through the code )
- shift+F8( Jump out of the way )
- F9( Step through the code Resume)
Breakpoint debugging case
Case 1 is executed circularly
package com.dzu.cn;
/** * @Author ChenRuXu * @Date 2022/2/14 22:23 * @Version 1.0 */
public class Debug01 {
public static void main(String[] args) {
// Demonstrate line by line execution
int sum=0;
for (int i=0;i<5;i++){
sum+=i;
System.out.println("i="+i);
System.out.println("sum="+sum);
}
System.out.println(" sign out for");
}
}
Click the left mouse button on the desired line and then perform breakpoint debugging .
After performing breakpoint debugging, the following page appears
Be careful :F9 Resume You can dynamically add breakpoints, which still take effect during execution 
F8 step over Skip step by step 
F7 step into Jump into method 
force step into Force into the method body 

here F7 We can see clearly the execution process of the program and the changes of variables .
Case 2 : Array out of bounds execution exception
package com.dzu.cn;
/** * @Author ChenRuXu * @Date 2022/2/14 22:48 * @Version 1.0 */
public class Debug02 {
public static void main(String[] args) {
int[] arr ={
1,10,-1};
for (int i = 0; i <=arr.length ; i++) {
System.out.println(arr[i]);
}
System.out.println(" sign out for loop ");
}
}

Case 3 tracking source code
Observe Arrays.sort(arr) How it's sorted
package com.dzu.cn;
import java.util.Arrays;
/** * @Author ChenRuXu * @Date 2022/2/14 22:56 * @Version 1.0 */
public class Dubug03 {
public static void main(String[] args) {
int arr[] ={
1,-1,10,-20,100};
Arrays.sort(arr);
for ( int i= 0;i<arr.length;i++){
System.out.print(arr[i]+"\t");
}
}
}
Learn to use breakpoints in debugging F7 Jump into the method body

Use F7 Later, we found that it did not enter the source code . Here is our solution .
Method 1 :force step into Use enforcement to enter
Method 2 adopts configuration method to realize
Find the option of breakpoint debugging in the settings .

Will be one of the java.* ,javax.* Uncheck the .
By default, it is not allowed to enter the source code
At this point we can use dubug To enter the source code debugging .
On this basis, if we are using F7 Will continue to enter .

This is where we really implement the sorting method ( Double quick row )
After entering the final source code , reflection How to exit to the main method
Jump out of the previous method first We need to use shift+F8( Jump out of the way ) Jump to the place where the call is sorted and step back to the main method

Case four :F9 resume And dynamic breakpoints
idea Support dynamic breakpoints during the running process
package com.dzu.cn;
import java.util.Arrays;
/** * @Author ChenRuXu * @Date 2022/2/14 22:56 * @Version 1.0 */
public class Dubug03 {
public static void main(String[] args) {
int arr[] ={
1,-1,10,-20,100};
Arrays.sort(arr);
for ( int i= 0;i<arr.length;i++){
System.out.print(arr[i]+"\t");
}
System.out.println(1);
System.out.println(2);
System.out.println(3);
System.out.println(4);
}
}

Use F9 It will go directly to the position of the second breakpoint . Then we dynamically add a breakpoint .
Now click F9 It will go to the position where the breakpoint is dynamically added 
summary
Debugging with breakpoints is , When we analyze the source code for troubleshooting and learning in the future, it is one of the essential contents .
边栏推荐
- How to use kotlin to improve productivity: kotlin tips
- Ffmpeg mix
- "Niuke brush Verilog" part II Verilog advanced challenge
- Market status and development prospect forecast of global heat curing adhesive industry in 2022
- 第十九届浙江省 I. Barbecue
- [BMZCTF-pwn] 20-secret_ file
- Matplotlib -- save graph
- MC Layer Target
- Jincang KFS data bidirectional synchronization scenario deployment
- Contents of welder (primary) examination and welder (primary) examination in 2022
猜你喜欢
![[free completion] development of course guidance platform (source code +lunwen)](/img/14/7c1c822bda050a805fa7fc25b802a4.jpg)
[free completion] development of course guidance platform (source code +lunwen)

I've been in software testing for 8 years and worked as a test leader for 3 years. I can also be a programmer if I'm not a professional

Internationalization and localization, dark mode and dark mode in compose

Human resource management system based on JSP

Web security - CSRF (token)

Leetcode simple problem delete an element to strictly increment the array

After job hopping at the end of the year, I interviewed more than 30 companies in two weeks and finally landed

Concurrent operation memory interaction
![[luatos sensor] 2 air pressure bmp180](/img/88/2a6caa5fec95e54e3fb09c74ba8ae6.jpg)
[luatos sensor] 2 air pressure bmp180

Sdl2 + OpenGL glsl practice (Continued)
随机推荐
JS multidimensional array to one-dimensional array
Handling record of electric skateboard detained by traffic police
论文阅读_ICD编码_MSMN
联发科技2023届提前批IC笔试(题目)
带有注意力RPN和多关系检测器的小样本目标检测网络(提供源码和数据及下载)...
I've been in software testing for 8 years and worked as a test leader for 3 years. I can also be a programmer if I'm not a professional
Writing skills of multi plate rotation strategy -- strategy writing learning materials
Two drawing interfaces - 1 Matlab style interface
Golang -- realize file transfer
[BMZCTF-pwn] 18-RCTF-2017-Recho
Thesis reading_ Tsinghua Ernie
论文阅读_中文医疗模型_ eHealth
《牛客刷verilog》Part II Verilog进阶挑战
"Niuke brush Verilog" part II Verilog advanced challenge
2022 registration examination for safety production management personnel of hazardous chemical production units and examination skills for safety production management personnel of hazardous chemical
Use the benchmarksql tool to perform a data prompt on kingbases. The jdbc driver cannot be found
4 years of experience to interview test development, 10 minutes to end, ask too
Sdl2 + OpenGL glsl practice (Continued)
I stepped on a foundation pit today
[set theory] binary relation (example of binary relation operation | example of inverse operation | example of composite operation | example of limiting operation | example of image operation)