"Go" Eclipse single-Step debugging

Source: Internet
Author: User

Enter debug mode, set breakpoints, and then run program to Breakpoint

[1] shortcut key (F8) executes the program directly.

[2] shortcut key (F5) step to execute the program, encountered when the method entered.

[3] shortcut key (F6) step into the program, encountered when the method skipped.

[4] shortcut key (F7) step into the program, jump out of the current method.

To change the value of a variable, you can right-click on the variable and select [change VariableValue] from the popup menu to bring up the modification screen. After changing its value, press the OK key. At this point, the value of the variable is changed to the modified value. To check if the code snippet is correct, you can select a sentence or a piece of code, right-click to select the inspect item in the popup menu, and the result of the code is displayed in the Expressions window.

When debugging, the source Notfind message appears, as long as the relevant project in Window->preferences->tomcat->sourcepath is selected.

1, put a breakpoint in the program, that is, to double-click the program to put breakpoints on the left side of the column.

2, click the Bug-like button, or right-click the program, select Debug AS--javaapplication

3, according to F5 is a layer of in-depth debug equivalent to peel onions, according to F6 is a step-by-step debug, ignore the deep-seated operation, according to F7 is no matter how deep the current position, all jump to the breakpoint set the layer of code, according to F8 is to stop debugging, run the program another, in the debug, There will be a lot of useful information displayed in the Debug box, you need to practice, the mouse pointer over the variable will have the current variable property values

Eclipse Breakpoint Debugging Eclipse Breakpoint Debugging when debug as application there are some buttons on the debug box, for example: Suspend,step into, step over,step return,drop to Frame,u SE stepfilters/step Debug What are they used for?

The local debugging Java debugger has a client/server design, so it can be used to debug programs that run locally (on the workstation where the debugger resides) or remotely (on another computer in the network). Local debugging is the simplest and most commonly used type of debugging. After you have finished editing and building your Java program, you can use the workbench to run > Debug ... menu item to start the program on the workstation. Starting the program in this manner establishes a connection between the debugger client and the Java program that is being started. You can then use breakpoints, stepping, or expression evaluation to debug your program.

Preparing for debugging

You can make your program easier to debug by following these guidelines: Try not to put more than one statement on the same line, because some debugger features run on a behavioral basis. For example, you cannot step over or set a line breakpoint on multiple statements on the same line. If you have source code, connect the source code to the JAR file.

To start a Java program in debug mode

Starting a program in debug mode allows you to use the debugger to suspend and resume execution of programs, examine variables, and evaluate an expression. To start the Java program in debug mode, in Package Explorer, select the Java compilation unit or class file that you want to start. Select Run > Debug mode > Java application. or choose Debug Mode > Java application from the drop-down menu on the Debug toolbar button. The program is now started, and the process that is started is displayed in the Debug view. If you want the program to stop in the main method so that you can step through its entire execution, create a Java application startup configuration and select the Stop check box in main on the main tab. You can also debug a Java program by selecting the project rather than compiling the unit or class file. You are prompted to select a class from the classes that define the Main method. (If only a class with the main method is found in the project, the class is started as if the class was selected.) )

Pending threads

To suspend an executing thread: Select the thread in the Debug view. Click the Suspend button in the Debug View toolbar. The thread will suspend its execution. The current call stack for the thread is displayed, and the current line of execution is highlighted in the editor in the debug perspective. When a thread is suspended, the top stack frame of the thread is automatically selected. The variables view displays the variables of the stack frame and their values. You can further examine complex variables by expanding complex variables to display the values of their members. When you suspend a thread and hover the cursor over a variable in the Java editor, the value of the variable is displayed.

Resume execution of a pending thread

To continue executing a pending thread: Select the thread or its stack frame in the Debug view. Click the Continue button (or press the F8 key) in the Debug View toolbar. The thread will continue to execute, but the stack frame will no longer be displayed for that thread. This clears the variables view. When you step through a Java program's execution of a pending thread, you can use single-step control to step through the execution of the program one line at a time. If a breakpoint is encountered while performing a single step, the execution is suspended at that breakpoint, and the single step is ended. Step over Select a stack frame in the Debug view. The current line of execution in the stack frame is highlighted in the editor of the debug perspective. Click the Step Over button in the Debug View toolbar, or press the F6 key. Executes the currently selected row, but suspends on the next executable line. Step into Select the stack frame in the Debug view. The current line of execution in the selected frame is highlighted in the editor of the debug perspective. Click the Step Into button in the Debug View toolbar, or press the F5 key. Invokes the next expression on the currently selected row to be executed, and execution is suspended on the next executable line in the called method. Step into selection Select the stack frame in the Debug view. The current line of execution in the selected frame is highlighted in the editor of the debug perspective. In the Java editor, in the current line of execution, place the cursor on the name of the method you want to step into. Click the Step into selection operation in the Run menu or the Java Editor context menu, or press the CTRL-F5 key. The execution continues until the selected method is called. Use filter stepping to toggle the Use Single Step Filter button in the Debug View toolbar, or use Shift+f5. When you switch this operation to ON, each step (step over, step into, and step back) applies the set of step filters defined in the user preferences (see Windows > Preferences > Java > Debugging > Stepping through filtering). When you invoke a step operation, stepping continues until you reach the unfiltered location or before you encounter a breakpoint. Run to return select the stack frame in the Debug view. The current line of execution in the selected frame is highlighted in the editor of the debug perspective. Click the Run to Back button in the Debug View toolbar, or press the F7 key. Execution continues until the next return statement in the current method is executed, and execution is suspended on the next executable line. When you run to a row suspend thread, you can continue execution until you perform the specified behavior. This is an easy way to suspend execution of a line without setting a breakpoint. Place the cursor on the line where you want the program to run. Choose Run To line from the pop-up menu, or use Ctrl+r. The program will continue to execute, just before the specified line to execute is pending. It is possible that a line has neverWill not be encountered, and the program will not be suspended. Breakpoints and exceptions can cause threads to be suspended until they reach the specified line. Check worth when you select a stack frame, you can see the visible variable in the stack frame in the variables view. The variables view displays the values of the base type. You can examine complex variables by expanding complex variables to display their members.

Evaluate an expression

When a VM suspends a thread (due to a breakpoint or stepping code), the expression can be evaluated in the context of the stack frame. Select the stack frame in which to perform the evaluation. For the details pane for variables and expression views, the evaluation context will be the selected variable. If no variable is selected, the stack frame you select will be the context. You can enter expressions and evaluate expressions in the following areas: Show view Expression View Details pane Variable View details pane Java Editor (when it is displaying a source and is not read-only) Select an expression that requires a value and choose Show, check, or execute from the context pop-up menu. The results of the display or check evaluation are displayed in a pop-up window. Note that execution does not show results-only the expression is executed. You can leave the results pop-up window by clicking outside the Pop-up window or by pressing ESC. By pressing the key sequence displayed at the bottom of the pop-up window, you can move the results to display view (if selected) or expression view (if checked is selected). For example, to move the results of a check evaluation to the expression view, press Ctrl-shift-i. Note that when you use the display action from the display view, the results are written to the display view instead of the pop-up window note: Evaluation cannot be performed on a thread that has been manually suspended.

The

client/server design for the remote debugging Java debugger allows you to start a Java program from a computer on the network and debug the program from a workstation running the platform. This is especially useful when developing programs for devices that cannot be in charge of the development platform. This is also useful when you are debugging a program on a dedicated machine, such as a Web server. Note: To use remote debugging, you must use a Java VM that supports this feature. To debug a program remotely, you must be able to start the program in debug mode on the remote machine so that it waits for a connection from the debugger. Specific techniques for starting programs and connecting to the debugger are VM-specific. The basic steps are as follows: Ensure that Java programs are being built with available debugging information. (You can control these properties from Windows > Preferences > Java > Compilers). After the Java program is built, install it to the target computer. This involves the. CLASS file or. The JAR file is copied to the appropriate location on the remote computer. Call the Java program on the remote computer and use the appropriate VM arguments to specify the debug mode and the debugger's communication port. Use the remote boot configuration to start the debugger and specify the address and port of the remote computer. You should obtain more specific instructions from the VM vendor to set up the startup configuration for remote debugging.

To start configuring a remote Java application using a remote Java application launch configuration should be used when debugging an application running on a remote VM. Because the application is started on a remote system, the boot configuration does not specify general information about the JRE, program arguments, or VM arguments. However, information about connecting to the application is provided. To create a remote Java application launch configuration, do the following: Select Run > Debug from the Workbench menu bar ... (or choose Debug from the drop-down menu in the Debug toolbar button ...) ) to display the Launch Configuration dialog box. Select the remote Java application in the list of configuration types on the left. Click the New button. A new remote boot configuration is created and three tabs are displayed: Connection, source, and public. On the Connection tab, in the Item field, enter or browse to select the item to use as the reference for the launch (for source lookup). You do not need to specify a project. In the host field of the Connection tab, enter the IP address or domain name of the host on which the Java program is running. If the program is running on the same machine as the workbench, enter localhost. In the port field of the Connection tab, enter the port in which the remote VM is accepting connections. Typically, you specify this port when you start a remote VM. The Allow terminating remote VM flag is a toggle switch that determines whether the terminate command is enabled in the debugger. Select this option if you want to be able to terminate the VM you are connecting to. Click Debug. Startup attempts to connect to the VM at the specified address and port, and the results are displayed in Debug view. If the startup program cannot connect to the VM at the specified address, an error message appears. Specifies the instructions that should be obtained from the VM vendor to set up the remote VM.

Disconnect from VM to disconnect from the VM connected to using the remote Java application startup configuration: In the Debug view, select Start. Click the Disconnect button in the view's toolbar. Communication with the VM terminates, and all threads in the remote VM continue. Although the remote VM continues to execute, the debugging session is now terminated.

"Go" Eclipse single-Step debugging

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.