Eclipse Debug Breakpoint "reprint"

Source: Internet
Author: User

The blog post is reproduced in other people's blogs, the original blog address: http://blog.csdn.net/maritimesun/article/details/7815903

As a developer, it is necessary to master the debugging techniques in the development environment. Last year, I wanted to summarize the debugging of Eclipse breakpoints, because the degree of control over time still needs to be greatly improved, and the result is not written this blog post until this year. There are a lot of Java debugging techniques, such as Java Debug interface, and so on, according to the needs of specific projects, there are many worth to study and study. This blog post is only a summary of the Eclipse breakpoint debugging techniques, not enough places to ask Daniel.

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, and the entire calling procedure, along with the code line number. Describe the meanings of these buttons separately. From left to right, respectively:

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

2. Interrupt the entire process

3. The current method is entered, and the shortcut key is F5.

4. Indicates that the next line of code is running, and the shortcut key is F6.

5. Means to exit the current method, return to the call layer, and the shortcut key to F7.

6. Returns the beginning of the current thread stack to begin execution.

1.2 Variable View

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

2. Show all the variable values

3. Variable values can be changed by this window

1.3 Breakpoint View


1. Show All Breakpoints

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

3. Exception Breakpoint

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

1.4 Expression View


The expression view is a more common view of the debug process, you can observe some of the variables you are interested in, you can add some of your own expressions, or you can see the results of a line of code running. 1. Expression 2. Click this to add an expression.

2 Types of breakpoints

2.1 Method Breakpoint

Breakpoints everyone is familiar with, in the Eclipse Java editing area of the wardrobe double-click to get a breakpoint, the code will run here when the stop. Method Breakpoint is hit at the entrance of the method.

The special point of the method breakpoint is that it can be hit in the JDK source code, because the JDK at compile time to remove debugging information, so the normal breakpoint is not hit inside, but the method breakpoint can be, this method can be used to view the call stack.

2.2 Item Breakpoint

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

Right-click at the breakpoint and select the last "Breakpoint Properties"

There are three options in the breakpoint attribute, enabling "enable", and hit count and conditional are selected according to our needs.

1) Hit Count is the number of times the code segment at the specified breakpoint is run, most typically a loop, and if you want a loop to execute 10 times on the thread to suspend, then specify the hits count value to 10, then the current loop executes to the nineth time when it hangs.

2) Conditional, as the name implies, is conditional judgment, for example, we need to loop variable i==10, when 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 select suspend when value changes, it may be suspended conditional when the value of the variable is changed.

2.3 Variable Breakpoint

A breakpoint can not only be hit on a statement, but a variable can also accept a breakpoint.

is a variable of the breakpoint, in the value of the variable initialization, or change the value of the variable can be stopped, of course, the variable breakpoint can also be conditional, and the above described conditional breakpoint settings are the same. Oh, this Part I did not go to practice, can not find where to set up ~

2.4 Modifying variable values

Changing the value of the variable is appropriate for the code to stop at the breakpoint, but the value passed is not correct, then you can modify the value of the variable to ensure that the code to take the correct flow, or that there is an abnormal branch is always going to go, can not be debugged to change the conditions, to see if the exception 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 values to view the changes in the window, save the Ctr+s saved, the value of the variable will be changed to a new value.

2.5 Re-commissioning

The fallback for this debug is not omnipotent and can only be rolled back in the current thread's stack frame, and can be returned at most to the beginning of the invocation of the current thread. On fallback, right-click on the thread method that requires fallback and select Drop to Frame

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

Eclipse Debug Breakpoint "reprint"

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.