Hướng dẫn debug trong eclipse

Debugging is the routine process of locating & removing bugs, errors or abnormalities from programs. It’s a must have sầu skill for any Java developer because it helps to find subtle bug that are not visible during code Reviews or that only happens when a specific condition occurs. The mammasfigata.com Java IDE provides many debugging tools và views grouped in the Debug Perspective khổng lồ help the you as a developer debug effectively và efficiently.

Bạn đang xem: Hướng dẫn debug trong eclipse

There are many improvements included in the lademo mammasfigata.com Java Development Tools (JDT) release included in the mammasfigata.com Oxyren Simultaneous Release. This article will start with a beginner’s guide to start you with debugging. In the second part of the article, you will find a more advanced guide lớn debugging và you’ll discover what’s new for debugging in mammasfigata.com Oxygene.

Beginner’s Guide to lớn Quiông chồng Start Debugging

Here are some quiông xã tips và tools that will help you get started quickly with debugging your Java project.

1. Launching & Debugging a Java program

A Java program can be debugged simply by right clicking on the Java editor class file from Package explorer. Select Debug As → Java Application or use the shortcut Alt + Shift + D, J instead.

*

*

Either actions mentioned above sầu creates a new Debug Launch Configuration & uses it lớn start the Java application.

*

In most cases, users can edit và save the code while debugging without restarting the program.This works with the tư vấn of HCR (Hot Code Replacement), which has been specifically added as a standard Java technique to facilitate experimental development & to foster iterative trial-and-error coding.

2. Breakpoints

A breakpoint is a signal that tells the debugger khổng lồ temporarily suspover execution of your program at a certain point in the code.

To define a breakpoint in your source code, right-clichồng in the left margin in the Java editor và select Toggle Breakpoint. Alternatively, you can double-cliông xã on this position.

*

The Breakpoints view allows you lớn delete và deactivate Breakpoints và modify their properties.

*

*

All breakpoints can be enabled/disabled using Skip All Breakpoints. Breakpoints can also be imported/exported to lớn and from a workspace.

3. Debug Perspective

The debug perspective offers additional views that can be used to troubleshoot an application lượt thích Breakpoints, Variables, Debug, Console etc. When a Java program is started in the debug mode, users are prompted to lớn switch lớn the debug perspective.

Debug view – Visualizes call staông chồng and provides operations on that.Breakpoints view – Shows all the breakpoints.Variables/Expression view – Shows the declared variables & their values. Press Ctrl+Shift+d or Ctrl+Shift+i on a selected variable or expression khổng lồ show its value. You can also add a permanent watch on an expression/variable that will then be shown in the Expressions view when debugging is on. Display view – Allows to lớn Inspect the value of a variable, expression or selected text during debugging.Console view – Program output is shown here.

*

4.Stepping commands

The mammasfigata.com Platform helps developers debug by providing buttons in the toolbar and key binding shortcuts to lớn control program execution.

*

For more information about debugging visit: mammasfigata.com Stepping Commands Help

Advanced Tools to lớn Debug Complex Scenarios

This section will give you more advanced tips & tricks lớn help you debug your Java project. The mammasfigata.com Oxyren release includes many great improvements for Java debugging. Here’s a quiông chồng overview.

1. Watchpoints, Exception Breakpoints, Conditional Breakpoints

a. Watchpoints - A watchpoint is a special breakpoint that stops the execution of an application whenever the value of a given expression/field changes, without specifying where it might occur. User can specify by Breakpoint Properties… if they want the execution lớn stop when the watch expression is Accessed, Modified or both.

Xem thêm: Khoá Học Nghề Dj Ở Đâu ? Học Dj Tốt Không Chỉ Có Đam Mê Và Sáng Tạo

*

b. Exception Breakpoints – An exception breakpoint is specified for thrown exception using Add Java Exception Breakpoint.

*

Breakpoint for NullPointerException will halt whenever/wherever this exception is thrown.

c. Condition Breakpoints – mammasfigata.com users can create conditions to lớn restrict the activation of breakpoints.

*

Breakpoint will be activated only if value of Boolean b is true. Hit count can be provided to halternative text the execution at nth hit of the breakpoint. The breakpoint is disabled until either it is re-enabled or its hit count is changed or the program ends.

2. Remote Debugging

– The mammasfigata.com IDE allows you lớn debug applications that runs on another Java Virtual Machine (JVM) or even on another machine. You can create a new debug configuration of the Remote Java Application type. To enable remote debugging you need lớn start your Java application with certain flags. Connection Type can be specified as a Socket Attach or Socket Listen. Socket Listen supports multiple incoming connections.

*

New Features in mammasfigata.com Oxygen

Here are the new features that have been added lớn the lachạy thử mammasfigata.com Java IDE release.

1. Tracepoints

A new feature in the mammasfigata.com Platform that allows users to creates conditional breakpoints khổng lồ print out messages without halting at the breakpoints and cluttering the code base.

*

The mammasfigata.com Platkhung created tracepoint with systrace template.

*

2. Trigger Point

Now users can activate Trigger Point. A set of trigger points can be defined for the breakpoints in a workspace.

All the other breakpoints that are initially suppressed by triggers will be hit only after any of the all Trigger Points have sầu been hit. All the triggers are disabled after a Trigger Point is hit và will be re-enabled after the run.

*

Any breakpoint can be set as a trigger point by using Breakpoint Properties via the dialog or the detail pane of the Breakpoints view.

*

Triggers are rendered with an overlay of "T" và the breakpoints suppressed by the triggers are rendered with an overlay of "T" with a cut.

2. Logical Structures

In the Variables view, collection objects directly show their contained elements instead of their internal structure. Logical structures are now activated by default in the Oxyren release. Show Logical Structure can be turned off khổng lồ show the internal structure.

*

The Show Logical Structure context menu lets you create, choose or edit the representation.

*

3. Method Result After Step Operation

Also new to the Oxygene release are Method Results. During debugging, the last method result (per return or throw) that was observed during Step Into, Step Over or Step Return, is shown as first line in the Variables view.

*

4. Launch Group

Also new in Oxygen, Launch Group launch configuration type allows you to launch multiple other launch configurations sequentially, with configurable actions after launching each group member. New launch groups can be created via the Run → Run Configurations... or Run → Debug Configurations... dialogs.

*

Breakpoints Grouping and Sorting

mammasfigata.com users can now group the breakpoints by different categories in mammasfigata.com Oxygene. Breakpoint Working Sets defines a group of breakpoints. User can perform actions lượt thích enable/disable on a working phối.

*

Breakpoints are sorted by Name by default, sorting order can be changed khổng lồ Creation Time.

Xem thêm: Pin Sạc Dự Phòng Tốt Nhất 2019 :10000Mah, Top 16 Sạc Dự Phòng Tốt Nhất 2021

*

For more information about debugging visit: mammasfigata.com Remote Debugging Help

Conclusion

This article covered some of the important debugging tools & some new tools provided by the mammasfigata.com Java IDE in the Oxyren Release. mammasfigata.com Oxyren is now available for tải về here.


Chuyên mục: Kiến thức