Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set breakpoints for debugging in IDEA

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "how to set breakpoints for debugging in IDEA". In daily operation, I believe many people have doubts about how to set breakpoints for debugging in IDEA. Xiaobian consulted various materials and sorted out simple and easy operation methods. I hope to help you answer the doubts about "how to set breakpoints for debugging in IDEA"! Next, please follow the small series to learn together!

Black background version:

First compile the program to debug.

1. set breakpoints

Select the line of code where you want to set a breakpoint and click the left mouse button after the line number area.

2. Start debugging session

Click on the bug pointed at 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 now resides, line 9 of the program in method f1(). The area where the red arrow hovers is the method call stack area of the program. In this area are displayed the methods that have been called up to the breakpoint, the lower the method, the earlier it was called.

3. step through

3.1 step over

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

3.2 step into

Click the button pointed to by the red arrow and the program will execute one line down. If the row has custom methods, run into custom methods (methods that do not enter the official class library). The specific steps are as follows:

Set breakpoint at f1() of custom method to execute debugging

click

3.3 Force step into

This button allows access to any method during debugging.

3.4 step out

If during debugging you enter a method (e.g. f2()) 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 was called. It is worth noting that this method has been implemented.

3.5 Drop frame

Clicking this button will return you to the point where the method was called (as shown above, the program will return to main()) to execute again, and the values of all context variables will return to that point. You can jump to any method in the call chain as long as there are other methods above it.

4. advanced debugging

4.1 Cross-breakpoint debugging

Set multiple breakpoints and start debugging.

To move to the next breakpoint, click the following:

The program will run the code that needs to be executed from one breakpoint to the next. If there is no breakpoint in the following code, clicking the button again will finish the program.

4.2 View Breakpoints

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

Arrow 1 points to the breakpoint you have set, and arrow 2 sets a conditional breakpoint (pause execution of the program when certain conditions are met, such as c==97). When debugging is finished, you should remove the breakpoint you set at arrow 1 (after selecting the breakpoint you want to remove, click the red minus sign above).

White background version:

First compile the program to debug.

1. set breakpoints

Select the line of code where you want to set a breakpoint and click the left mouse button after the line number area.

2. Start debugging session

Click on the bug pointed at 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 now resides, line 11 of the program in method f2(). The area where the red arrow hovers is the method call stack area of the program. In this area are displayed the methods that have been called up to the breakpoint, the lower the method, the earlier it was called.

3. step through

3.1 step over

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

3.2 step into

Click the button pointed to by the red arrow and the program will execute one line down. If the row has custom methods, run into custom methods (methods that do not enter the official class library). The specific steps are as follows:

Set breakpoint at f1() of custom method to execute debugging

click

3.3 Force step into

This button allows access to any method during debugging.

3.4 step out

If during debugging you enter a method (e.g. f2()) 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 was called. It is worth noting that this method has been implemented.

3.5 Drop frame

Clicking this button will return you to the point where the method was called (as shown above, the program will return to main()) to execute again, and the values of all context variables will return to that point. You can jump to any method in the call chain as long as there are other methods above it.

4. advanced debugging

4.1 Cross-breakpoint debugging

Set multiple breakpoints and start debugging.

To move to the next breakpoint, click the following:

The program will run the code that needs to be executed from one breakpoint to the next. If there is no breakpoint in the following code, clicking the button again will finish the program.

4.2 View Breakpoints

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

Arrow 1 points to the breakpoint you have set, and arrow 2 sets a conditional breakpoint (pause execution of the program when certain conditions are met, such as c==97). When debugging is finished, you should remove the breakpoint you set at arrow 1 (after selecting the breakpoint you want to remove, click the red minus sign above).

4.3 Set variable values

After debugging starts, you can assign values to specified variables in the area pointed to by the red arrow (left mouse button to select variables, right mouse button to pop up menu and select setValue...). This feature allows you to detect conditional and loop statements more quickly.

At this point, about "how to set breakpoints in IDEA debugging" learning is over, I hope to solve everyone's doubts. Theory and practice can better match to help you learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report