★eclipse Debug Interface Application detailed--eclipse debug a secret that's not known

Source: Internet
Author: User
Tags ming
Browsing Csdn Today, we found a detailed description of the various points of knowledge in Eclipse Debug. Hereby record. Eclipse Debug a secret that's not known http://blog.csdn.net/mgoann/article/details/7239492 Debug View

Understanding the Debug view, the Red section box is the thread stack view, the yellow section box is an expression, a breakpoint, a variable view, and the blue part is Code view.
Thread Stack View

Explain the meaning of these buttons individually:

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. Represents the stack of the current thread, from which you can see what code is running, the entire calling procedure, and the Code line number



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



Breakpoints View

1. Show All Breakpoints

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

3. Exception Breakpoint



An expression view

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 type

2. Click here to add an expression



Code view

Code view: Used to display specific code. Where the green part refers to the code that will be executed currently

Scene One: Xiaoming has worked hard for two days to finally complete his own task, the second day after the test found Xiaoming said, Xiaoming's program has bugs, can be Xiao Ming after careful debugging, found that there is no problem, but the test environment does have problems, so xiaoming encountered a problem, testing the environment of Linux, Can not go to the Linux to debug, xiaoming this time to want to be Linux can also debug the good. Remote Debug

Remote debug: Remote Debug, as the name suggests, can debug any Java on a remote operating system, but only if there is a local need for synchronized code.

1. The procedure for remote debug is to increase the number of unique Java processes on the remote operating system

-xdebug-xnoagent-djava.compiler=none-xrunjdwp:transport=dt_socket,address= $DEBUG _port,server=y,suspend=n

2. Create a new remote Java application in Eclipse debug

1. Turn on the Debug configurations view

2. Right-click Remote Java Application,

New

3. Select Source Engineering

4. Enter remote IP and port, port is service

End of the $debug_port, click OK.

Scene One: Xiaoming wrote a task performer, the performer of the continuous implementation of some tasks, in the current online operation for a period of time, found that there are some probability of failure, found that after running for some time, the task of abnormal exit, exit because it is a null pointer, you can xiaoming want to be in the local debug, I don't know where the breakpoint hits, the problem is a probability event, not necessarily appear, so xiaoming debug several times down, dizziness, even the code can not see clearly, xiaoming would like to have a breakpoint whenever there is an exception to the null pointer when the stop to let him find the problem, it should be much better. Exception Breakpoint

Exception breakpoint: In the process of locating the problem, you often encounter breakpoints can not hit the appropriate location, and the problem of the trigger point is very different, so this time may try to try the exception breakpoint, as the name suggests, the exception breakpoint is to throw some kind of exception after the automatic suspend breakpoint.

Click on the red part to add an exception breakpoint



Enter the type of exception you want to locate, such as nullpointerexception, so that when any NullPointerException exception is thrown in the system, the current thread is suspended, giving you the opportunity to locate the problem.

Scene One: Xiao Ming wrote a huge cycle, in the debugging code, Xiaoming found that whenever the cycle to the 100,000th time, is the problem, did not reach their own expectations, so xiaoming in the loop hit a breakpoint, want to see what is going on, but Xiaoming never thought, How difficult it is to reach 100,000 cycles, Xiaoming has begun to think this time, if you can have such a breakpoint:

If loop = = 100000, thread stops to conditional breakpoint

Like the right figure, loop 1000 times if you want to loop to 500

Time to stop, you can create a conditional breakpoint, right

The hit breakpoint hangs breakpoint Properties.



Select Enable Condition

In the margin, add your own condition, if the condition returns True, the thread is suspended, and if False, the exception is ignored

Hit count is the number of times the breakpoint has passed, the thread is officially suspended, and if set to 500, the first 499 times is expressed, and the breakpoint does not stop, and the NO. 500 time the breakpoint suspends the current thread.

An expression

An expression can view some of the command lines that are not in the current code to facilitate locating problems.

Scene One: Xiaoming recently encountered a problem, in the call to a Third-party plug-in will always have problems, xiaoming suspected is a Third-party plug-in bug, but Xiaoming did not find the source code can not be debug, Xiao Ming how to do it. Debug locating a Third-party plug-in problem

1. Decompile the code using the Decompile tool

2. will be back to compile the source code to filter

3. Fix source code compilation error

4. Some experience in debug debug

1. To minimize debug and debug, good programmers always spend 80% of their time thinking about how to solve the problem, 20% of the time to complete the code, and bad programmers always 20% of the time to write code, 80% of the time to debug the code, try to think about how to do before, and have done a full experiment for your own ideas.

2. Improve debug efficiency as much as possible, set appropriate breakpoints, and use shortcut keys.

3.debug F6 shortcut keys are often used, it and PowerWord shortcut key conflict, so in the debug when the best will be powerword off.

The 4.debug expression is executable code that will have a permanent effect on the results of the code and, when debugging, be aware that the unused expressions are often cleared away.

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.