![]() |
Studio provides a smart debugger that enables to find and fix bugs across all tiers of an enterprise application. It can be configured to debug the business logic in an EJB. Use the debugger to:
Remote debugging is done when an application runs on one computer and debugging is done from another. It is useful when an application encounters a problem on a networked computer and cannot be duplicated on other computer. The computer used to debug a remote application is a Client computer and where the application is deployed is called a Remote computer.
The order in which a VM maintains stack frames is stack trace. The control flow is organized bottom up. Studying the stack enables to see how the control reached a point.
VM maintains the local variables on the stack separately for each namespace. This is called the Stack Frame. When the control flows from one namespace to another, variables in the new namespace are maintained separately on a different Stack Frame.
The stack trace shows all frames including those for which source is not available. It displays the class and local variables at that location. To open the reference file, click the method under Thread Viewer tab.
The editor contains the pop-up menus for toggling break points set in Java or JSP code. The editor highlights the line where the control is paused.
Displays the output for a debugging operation.
It lists the user threads that are suspended, and also shows the thread hierarchy.
Adds a watch to the selected text and debugger pauses when it encounters a watch point.
Displays the stack frame.
To start the debugger:
Use this tab when application to be debugged is deployed on one of the configured servers inside Studio
.
Use this tab when the application to be debugged is deployed on a remote server. Enter the Name to identify the application and enter the following information:
To explicitly start Server in debug mode, select Debug > Debug Server from the main menu. Right click on the desk in the explore panel and select Deploy. This deploys the desk using Express Development. If there are missing references or incomplete mappings, the Deploy Tool appears where the required details should be entered.
To launch a JSP in a browser, right click on a JSP such as bank.jsp and select Run. The specified browser comes up with the following URL: http://127.0.0.1:8181/bankWeb/bank.jsp where bankWeb is the context root for the application.
Insert breakpoints on an executable line of Java or JSP code before or after starting the Debugger. To insert a breakpoint, place the cursor at the suitable position in the editor and do one of the following:
When the execution of a thread reaches a breakpoint, it pauses. To inspect the stack for this thread, open the `Stack Frame Viewer' tab in the output panel. Other threads execute asynchronously but are not shown in the dropdown.
To view the Beakpoints panel, select Debug > Add Line/Method/Exception Breakpoint from the menu bar; configure properties.
For details, read the sections on line, exception and method breakpoints, and field watchpoints.
Place the cursor at the suitable position in the Editor and click in the gutter. To modify the properties of a line breakpoint, right click on the breakpoint and select Properties. Enter the following details:
Select Debug > Add Exception Breakpoint from the main menu or right click on a breakpoint in the gutter and select Properties.
In the Exception Breakpoint panel, click Add. The Add Exception Breakpoint panel appears. Select from the options:
Provide the following details:
Select both the options to pause the Debugger in both cases.
Place the cursor at a method in the Editor and select Debug > Method Breakpoint from the main menu or introduce a breakpoint by clicking in the gutter, right click and select Properties > Method Breakpoint. The options are:
Provide the class name for example, pkg.Test and a field name. Debugger pauses when the concerned field is accessed from anywhere within the application. Details are displayed in the Watches tab in the output panel.
Debugger enables you to evaluate any variable in the stack frame. To do this, click evaluate expression button in the Debugger tool bar and follow these steps:
To remove a breakpoint:
Once breakpoints are set and Debugger starts, the following functions can be performed after reaching the first breakpoint:
The debugger pauses at the breakpoint. It is possible to step into a method, step out, or step over a method, and resume the thread that has been suspended. For details, read the following sections.
Select Debug > Step In from the main menu or click Step In icon in the Debugger toolbar.
If the next line of code is not a method call, the Debugger executes the code on the next line and pauses there.
If the next line of code is a method call, Debugger stops at the first line of code of the method that has been called, provided you have the source code for it.
If the source code for the method called is not available, Debugger executes the method while step in remains the same as at the point of invocation.
View all the class variables and local variables in the Thread Viewer tab.
To step over a method, select Debug > Step Over from the main menu or click Step Over in the Debugger toolbar. Irrespective of the next line of code being a method call or not, Debugger executes the line of code, and the control stops at any breakpoint it encounters, or immediately after. This is conditional on the availability of the source for the next line of code to be executed. Debugger does not stop if the next line of code is in another class for which the source is not available.
To step out of a method, select Debug > Step Out from the main menu or click Step Over in the Debugger toolbar. Debugger executes the current method and the control stops at any breakpoint encountered during execution or immediately after and returns the control to the calling method.
This process is conditional if the source code is available. When execution of a logical block of code ends, debugger pauses at the beginning of the block and highlights the point of step in, step over, or step out. For a line of code that is not a break or return statement, the following holds good:
|
Step In/Step Over at
|
Highlight Position
|
|---|---|
|
Last line in a try block
|
Beginning of the try block
|
|
Last line of method
|
Declaration of method
|
|
Last line of condition
|
The condition
|
The above is true of any JPDA compliant debugger. If a line of code has multiple statements implicit or explicit, after a step in debugger still highlights the same line as the debugger tries to step into the method calls it encounters and bounces back as the source is not available. For example, System.err.println("The value of object x is "+x);
Here the overloaded operator actually is a method call to the append() method of class StringBuffer and the call to toString() method of object x is not so obvious.
For remote debugging of applications using Studio the procedure is:
JavaServer Pages are converted into servlets and servlets are compiled to get the .class file. The Debugger maintains a one-to-one map of lines in the servlet that is created at compilation time to lines in the JSP. When a breakpoint is set in a JSP, the Debugger reads the map and sets the breakpoint in the corresponding line in the Servlet. Subsequently, breakpoint or step-in events return the appropriate lines in the JSP. This makes JSP debugging smooth.
EJBs allow to write complex business components in a single-threaded fashion though, inside the application server, the EJB runs in a multi-threaded environment.
A bean call invokes a function on a stub. Studio Debugger discovers calls made to bean methods and sets implicit break points in the bean code, automatically.
A thread re-directed from a breakpoint in the JSP to the bean code, hits the implicit breakpoint and pauses. This control flow to the method is similar to a Java step-into process.
Applications deployed on Oracle and WebLogic Servers can also be debugged from inside Studio. For details. read `Working with WebLogic Server 6.1' and `Working with Oracle 9iAS'.
Click disconnect in the Debugger tool bar. This functions differently for different types of debugging:
| Pramati Technologies © Copyright |
|