GuidePedia

0

The tutorial below explains debugging java applications through Eclipse. Debugging assists us in identifying and fixing defects in the application. The tutorial will focus on run-time issues and not compile time errors. You also have command line debuggers like gdb.
As stated on javapapers.com, this tutorial focuses on GUI based debugger by taking our favourite IDE Eclipse to run across the tutorial.
1. Conditional Breakpoint - From the perspective of debugging, ‘Breakpoints’ view will enlist the breakpoint created. You can add a boolean condition to it. The breakpoint will get activated and execution will be there only if the boolean condition is fulfilled or else this breakpoint will be skipped.
2. Exception Breakpoint – From the Breakpoint’s viewpoint, there is a button labeled as J! You can use this button to add a java exception based breakpoint. For instance, you would like the program to stop and allow debugging once a NullPointerException is put in, you can add a breakpoint by using this.
3. Watch Point – Once a selected attribute is accessed or modified program execution will stop and permit debugging. Choose a class variable in Outline view and from its context menu choose Toggle Watchpoint which will make a watch point for that attribute listing it in Breakpoint’s view.
4. Evaluation (Display or Inspect or Watch) - Ctrl+Shift+D or Ctrl+Shift+I on a chosen variable or expression will display its value. You can add a permanent watch on an expression/variable that will be displayed in Expressions view when debugging is on.
5. Change Variable Values – You can modify the value of a variable on the fly at the time of debugging. Select a variable and go to Variables view and choose the value, type and enter.
6. Stop in Main - In Run/Debug Settings, Edit Configuration, you can allow a check box that states Stop in main. Once enabled at the time of debugging a java program, which launches with a main method, the execution stops at first line of main method.
7. Environment Variables – In place of going to System properties to insert an environment variable, you can in a convenient way add it via Edit Configuration dialog box.
8. Drop to Frame - You can just return the control to any frame in the call stack at the time of debugging. Once change is made variables will not be reset. Select the stack level that you want to go back and restart debugging from there and click the drop to frame button from debug toolbar.
9. Step Filter – Once you Step Into (F5) which is a method, you may go into external libraries (like java) that you may not require. You can also add a filter in preferences and not opt for packages.
10. Step Into, Over and Return -
F5 – Step Into: moves over to subsequent step and if the current line has a method call the control will go into the first line of the called method.
F6 – Step Over: moves over the control to subsequent line. If there is a method call in the current line, it executes the method call internally and just moves the control to next line.
F7 – Step Return: When done from inside a method the control will move over to the calling line from where the current method is called.
F8 – Moves over to next breakpoint.

Post a Comment

 
Top