Eclipse Debugging methods

Source: Internet
Author: User

http://blog.jobbole.com/93421/

First, the Eclipse debugging introduction

Second, Eclipse and debug related views 2.1 Debug View 2.2 Variables View 2.3 Breakpoints View 2.4 Expressions view 2.5 Display View

Third, Debug

3.1 Setting breakpoints

3.2 Debugging Programs

3.2.1 Debugging native Java language programs

3.3.2 Remote debugging first, Eclipse debugging introduction

Anyone who has used eclipse knows that eclipse comes with a Java debugger and can provide a lot of basic debugging capabilities. The Eclipse Platform Workbench and its tools are built around the JDT component, which provides the following features for Eclipse:

Project management tools perspectives and view constructors, editors, search and build features debugger II, Eclipse and debug related views

Figure 1. General view of the Eclipse debug perspective (this view can be accessed by clicking the Debug button in the upper-right corner of the Eclipse interface)

Debug View:

The debug view allows you to manage the programs you are debugging and running on the workbench, and he displays the stack frames for the suspended threads in the program you are debugging, and each thread in the program appears as a node of the tree. He shows the process of each target that is running. If the thread is suspended, its stack frame is displayed as a child element. Here are some common debug buttons:

Skip all Breakpoints:: Set all breakpoints to be skipped, after setting the skip all breakpoints, there will be a slash on all breakpoints, indicating that the breakpoint will be skipped and the thread will not be suspended at that breakpoint.

Drop to Frame: This command allows the program to return to the beginning of the first line of the current method to start execution again, you can re-execute the Java stack frame, you can select a specified stack frame, and then click on the Drop to frame, so that you can re-enter the specified stack frame. Note When using drop to frame:

1. You cannot drop to a method in a method stack that has been executed.

2.drop into a stack frame does not change the original value of the global data, for example, a vertor containing an element is not emptied.

Step Filters: This function is relatively simple, when we want to ignore some of the classes we do not care about when debugging, you can turn on step Filters to filter, the program will continue until it encounters an unfiltered position or breakpoint. The step Filters function is comprised of the use step filters,edit step Filters,filter type,filter package four. Here's how:

Step Filtering, Debug, Java, 1:windows, Preferences.

Step 2: Select ' Use Step Filters '.

Step 3: Select the desired option on the screen. You can add some code from your own code base.

Step 4: Click ' Apply '.

In principle, the Edit Step Filter command is used to configure the step filter rule, while the filter type and the filter package refer to the filtered Java type and Java package respectively.

Step return: Jump out of the current method, and in the execution of the called method, use step return to jump out of the method after executing all the code of the current method and return to the method that called the method.

Step over: When stepping, when a child function is encountered inside a function, it does not step into the sub-function, but instead executes the child function throughout the stop, that is, the entire function as a single step.

Step into: Stepping, encountering sub-functions and continuing stepping

Resume: Resumes the suspended thread and jumps directly from the current position to the next breakpoint position.

Suspend: Pauses the selected thread, this time can be browsed or modified code, check data and so on.

Eclipse supports thread suspend and resume through suspend and resume. In general, suspend is suitable for debugging multi-threaded applications, and when it is necessary to view the stack frame and variable values of a thread, we can suspend the thread through the suspend command. Resume is used for recovery. There are two types of resume to note: The first is when you modify the program code during debugging, then save, click Resume, and the program hangs at the breakpoint. The second is that when the program throws an exception, the resume is run and the program is suspended at the breakpoint.

Terminate:eclipse the debug of the local program is terminated by the Terminate command.

Disconnect:eclipse uses the Disconnect command to terminate the socket connection to the remote JVM. Variables View:

Variables View displays variable information related to the stack frame selected in Debug view, and when you debug a Java program, the variable can optionally display more detailed information in the details pane. In addition, the Java object can display the value of the property it contains. There are many things you can do with the right mouse click of a variable in the window, and the main actions are the following:

All Instances: Opens a dialog box to display all instances of the Java class, which requires a Java virtual machine to support the retrieval of the instance.

All References:: Opens a dialog box to display all Java objects that reference the variable.

Change value: Changes the values of variables that can be used in conjunction with drop to frame for program debugging. Use these two functions to replace the re-debug

Copy Variables: The value of the copied variable, especially if the variable value is very long (such as JSON data), this feature comes in handy.

Find: Sometimes when there are a lot of variables in a class, you can look for them. Breakpoints View:

Breakpoints View will list all breakpoints you have set in your current workspace, and double-click the breakpoint to enter the location of the breakpoint in your program. You can also enable or disable breakpoints, delete, add new, and group them according to the workgroup or point hit count. The following two tips are useful for using breakpoints:

Hit count: Is the code snippet at the specified breakpoint run how many times, the most typical is the loop, if you want a loop to execute 10 times on the thread hang, then specify the hits count value is 10, then the current loop execution to the nineth time will be hung off.

Conditional: As the name implies, is conditional judgment, such as when 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, the expression and value settings are not valid. If you select suspend when value changes, it may be suspended conditional when the value of the variable is changed.

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.