Eclipse Breakpoint Debugging

Source: Internet
Author: User

As a developer, it is necessary to master the debugging techniques in the development environment. Last year I tried to summarize the Eclipse breakpoint debugging, because the control of time still needs to be greatly improved, the result is dragged until this year to write this blog post. There are a lot of Java debugging technology, such as Java Debug interface, according to the needs of specific projects, there are many worthwhile to study and learn. This blog post is only a summary of Eclipse breakpoint debugging techniques, not enough places to ask Daniel to advise.

1 Debug View

1.1 Thread Stack View

The thread stack view represents the stack of the current thread, from which you can see what code is running, the entire calling procedure, and the line number of the code. Explain the meaning of these buttons separately. From left to right, respectively:

1. Indicates that the current implementation continues to run until the next breakpoint, the shortcut key is F8.

2. Express interruption of the whole process

3. Means to enter the current method, shortcut key for F5.

4. Indicates running the next line of code, shortcut key for F6.

5. Indicates exiting the current method, returning to the call layer, and the shortcut key is F7.

6. Indicates that the start of the current thread stack is returned to execution.

1.2 Variable View

1. For variable name view, display all accessible instance variables and local variables in the current line of code

2. Show all values of variables

3. You can change the value of the variable by this window

1.3 Breakpoint View


1. Show All Breakpoints

2. Disable the port selected in the current Window 1 and click Enable again.

3. Exception Breakpoint

Often meet some exceptions, and then the program to exit, to find out where the anomaly occurred is more difficult, fortunately, you can hit an abnormal breakpoint. Where the exception is, the current thread hangs.

1.4 Expression View


An expression view is a more commonly used view in the debug process, you can observe some variables of interest to you, you can add some of your own expressions, or you can see the results of a line of code running. 1. Expression 2. Click here to add an expression.

2 Types of breakpoints

2.1 Method Breakpoint

Breakpoints are familiar, the wardrobe in the Eclipse Java editing area will get a breakpoint and the code will stop when it runs here. Method Breakpoint is hit at the entrance of the method.


Method Breakpoint is unique in that it can be played in the JDK source code, because the JDK in the compilation of the debugging information removed, so the normal breakpoint can not hit the inside, but the method breakpoint is possible, you can see the method of the call stack.

2.2-Piece Breakpoint


A conditional breakpoint, as its name implies, is a breakpoint with a certain condition, and the code will stop when it runs to the breakpoint only if the user's settings are met.

Click the right mouse button at the breakpoint to select the last "Breakpoint Properties"


There are three choices in the breakpoint properties, enabling "Enable", Hit count and conditional are selected according to our needs.

1 Hit Count is the number of times the code snippet at the specified breakpoint is run, and the most typical is the loop, and if you want a loop to be suspended 10 times on the thread, specify a Hit Count value of 10, and the current loop will be dead by the nineth time.

2 Conditional, as the name suggests, is the condition to judge, for example we need to loop variable i==10, the thread hangs, the condition is set to i==10, select suspend when "true".

If the above hit count and conditional are selected, it will be effective if the expression and value settings are unreasonable. If you choose suspend when value changes, you may suspend conditional when the value of the variable changes.

2.3 Variable Breakpoint

A breakpoint can be used not only on a statement, but also in a variable that accepts a breakpoint.

The image above is a hit breakpoint of a variable, when the value of the variable is initialized, or the variable value changes can be stopped, of course, the variable breakpoint can also be conditional, and the introduction of the conditional breakpoint set is the same. Oh, this Part I did not go to practice, can not find where to set ~

2.4 Modifying the value of a variable

Modifying the value of a variable applies when the code stops at the breakpoint, but the value is not correct, then you can modify the value of the variable to ensure that the code to go the correct process; or that there is an exception branch is always in, can not debug the condition, look at the abnormal branch code is correct.

In the Variables small window of the debug view, we can right-click on the variable and select "Change Value ..." Modify the value of the variable in the dialog box that pops up.

or in the following Value view window to modify, Ctr+s save, the value of the variable will be changed to the new value.


2.5 The rollback of this debugging is not omnipotent, it can only be rolled back in the current thread's stack frame, and it is said that it can only be returned to the beginning of the call to the current thread. When you roll back, right-click on the threading method that needs to be rolled back, and select Drop to Frame .


About breakpoint debugging, as well as the exception breakpoint, has been mentioned in the Dubug view, as well as remote debugging. Because I have not tried, so look forward to the next blog post.










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.