Eclipse myeclipse debug details

Source: Internet
Author: User
Eclipse myeclipse debug details Address: http://guoliangheyuqin.iteye.com/blog/1634184I don't know if you don't like debugging programs in eclipse or myeclipse when you first started learning Java. However, debug is a very useful debugging tool.

Therefore, you must learn debug well when using myeclipse.

 

1. Set the main Java class of the project in the debugging configuration.


 

2. Set breakpoints: set breakpoints.

When you start the application for debugging, eclipse automatically switches to the debug perspective. No doubt

Q: The most common debugging step is to set breakpoints so that you can check the variables and

Value. To set a breakpoint in the package explorer view of the Java perspective, double-click the selected source

Code file, open it in an editor. Traverse the code and place the cursor on the mark of a line of suspicious code

On the note bar (on the left side of the editor area), double-click to set the breakpoint.



 

Now, start the debugging session from the run> Debug menu. It is best not to place multiple statements on one row,

Because it cannot be executed in one step or set a line breakpoint for multiple statements on the same line.


The arrow in the left margin of the view indicates the row currently being executed




 

There is also a convenient breakpoint view to manage all breakpoints.




Conditional breakpoint

Once you know where an error occurs, you may want to know what the program is doing before the program crashes. One method is to execute each line of the program in one step. Execute one line at a time until the line of code is run to the suspicious line. Sometimes it is best to run only a piece of code, stop it in the suspicious code, and check the data at this location. You can also declare a condition breakpoint, which is triggered when the expression value changes. You can also use the Code help when entering a conditional expression. Set a conditional breakpoint trigger

To calculate the expression value in the debug perspective Editor, select the line of code that sets the breakpoint. In the context menu, press Ctrl + Shift + I or right-click the variable you are interested in (see figure 7) and select the inspect option. In the context of the current stack framework, the expression value is calculated and the result is displayed in the expressions view of the display window. Figure 7. Using the inspect option to calculate the expression value



 

 

Cut activity code

The display view allows you to process a variable by cutting the activity code. You can enter the variable name in the display view, and the view will prompt you with a familiar content assistant.
When the debugger stops at a breakpoint, you can select the step over option from the debug view toolbar to continue the debugger session. This operation will go beyond the highlighted line of code and continue to execute the next line of code in the same method (or continue to execute the next line of code that calls the method of the current method ). Variables that change after the previous step are highlighted in a certain color (Yellow by default ). The color can be changed on the debug preferences page.



To suspend an execution thread in the debug view, select a running thread and click suspend in the toolbar of the debug view. The current call stack of this thread is displayed, and the currently executed code line is highlighted in the editor in the debug perspective. When a thread is suspended, place the cursor over the variable in the Java editor, and the value of this variable will be displayed in a small hover window. In this case, the top stack framework of the thread is automatically selected, and the visible variables are also displayed in the variables view. You can check variables by clicking the appropriate variable name in the variables view. Hot Swap Error Correction: dynamic code correction. If Java Virtual Machine (JVM) v1.4 or a later version is run, eclipse supports hotswap bug fixing) JVM v1.3 or a lower version does not support this function. This function allows you to change the source code in a debugger Session, which is better than exiting the application, changing the code, re-compiling, and starting another debugging session. To use this function, modify the code in the editor and then re-debug it. JVM v1.4 is compatible with the Java platform debugger architecture (Java platform debugger architecture, JPDA. JPDA allows you to replace the modified Code in a running application. This is particularly useful if the application has been started for a long time or when it fails to be executed. If the program has not been fully executed yet, select the terminate option in the context menu of the debug view. An easy mistake is to use DEBUG or run in a debugger session, rather than resume. This will start another debugger session instead of continuing the current session.


1. step into (also F5) Jump to 2. step over (also F6) skip 3. step return (also F7) after the current method is executed, return jumps out of this method4.step filter and continues to be filtered until the unfiltered position or breakpoint is encountered (set filter: window-preferences-Java-debug-step filtering) 5. resume re-runs debug until it encounters a breakpoint. For example, if two breakpoints A and B are found to be useless during the debug process, and the breakpoint is removed, running resume will skip a and directly reach the B breakpoint. 6. The hit count setting is suitable for the For Loop (Set breakpoint view-right-click hit count) in the program. 7. Inspect checks the operation. Execute an expression to display the execution value 8. watch monitors changes to objects, methods, or variables in real time. we often say that the breakpoint (breakpoints) refers to line breakpoints. In addition to linebreakpoints, there are other breakpoint types: field (watchpoint) breakpoint, methodbreakpoint, exception breakpoint.10.field breakpoint is also called watchpoint) when the member variables are read or modified, 11. run-methodbreakpoint (run-methodbreakpoint) 12. add exception breakpoint to catch execption temporarily (To be continued ...) breakpoint attribute: 1.hit count is used for loop 2. enable condition will be suspended when it meets your input conditions (if it is true or changed) 3. this thread is temporarily suspended when suspend thread is multithreading. 4. suspend VM temporarily hangs on VM 13. variables in the variables view can change the variable value. In the variables view, right-click the variable and choose -- change value. for quick debugging. 14. after some code is modified in the debug process, --> Save & build --> resume temporarily at the breakpoint 15. resume when debug runs out of an exception, run resume and start debugging again from the breakpoint 16. if there are many methods in a row, when you press F5 for the first time, you will jump into the first method in this row, F6 step by step debugging, F7 will jump out of this method. when you press F5 for the second time, you can jump into the second method of this line. F6 performs step-by-step debugging and F7 jumps out of this method. and so on. to enter the first few methods of this line, press F5 and f7.

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.