Eclipse Debug skills, I a good colleague summed up, hope to be useful to everyone.

Source: Internet
Author: User

Basic Debugging Techniques

1. Quickly find where a bug is located.

Use the binary lookup method. The module of the bug is roughly divided into several steps, starting from the middle of the break point, and then through debugging to determine whether the problem is in front of the breakpoint or behind, and then use the binary search method to continue debugging, so loop 3, 4 times, basically can determine where the problem.

2. Change the parameter to the value you want when debugging.

Debugging sometimes need to look at the different parameters of the program go to where, but re-operation again very troublesome, this time, you can try to directly in the debug process to change the parameter value.

2.1 For the base data type, open the variables view to change the value directly, as shown in:

2.2 For object changes, in the variables view, right-click on the object to select "Change Value ...",

Re-assign the object in the box that appears. As shown in the following:

3. Add conditional Viewer when debugging.

3.1 First write in the file you want to view the code, then select it, right mouse button, select Watch, then we will see the expressions view is open, just write the code and its value will appear. As shown in the following:

PS: Open the expressions view directly, then add new expression is also possible.

The inspect function is similar to watch, except that it is used for temporary viewing and watch is permanent.

You can also change the condition view directly

4. Breakpoints View

4.1 When debugging we will hit a lot of breakpoints, but sometimes not every step needs to execute, this time you can open the Breakpoints view, the front of the tick off.

4.2 Sometimes we want to let the program completely finished, but do not want to remove all the breakpoints at this time click on the button below is OK, very convenient.

4.3 Sometimes the loop is executed too many times, but we just need to look at one of the values, and if we keep pressing F6, we select this breakpoint, tick hit count, enter the number of times you want to see it, save it, run Tomcat, The program will run directly to where we want it. As shown in the following:

4.4 Add conditional execution. During the debug process, we add conditions that allow the program to execute where it wants to go. You can tick contional in the breakpoints and enter the criteria in the text box that appears, so you must save it before you execute it. As shown in the following:

4.5 If the program directly error, you can click on the button, and then enter the error message, you can find out where the error, or look at the printed stack, find the error line.

5. When debugging, if you want to run a program executed again, but do not want to start over, this time, you can in the Debug view, select the method you want to execute again, right mouse button, select Drop to Frame.

Or simply click on the button shown, or you can return to execute again.

Eclipse Debug skills, I a good colleague summed up, hope to be useful to everyone.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.