Using Debugging Commands

 <  Day Day Up  >  

You can't perform debugging unless there's a way to walk through the code in the application. Workshop offers several commands to do this on the toolbar or through the Debug menu.

Step Into

If you select the Step Into command, the code runs line by line. If a line contains more than one statement, all statements are executed when you step into the next line.

This command is useful when debugging pieces of code that contain logic requiring a lot of processing. This enables you to halt at every line and check the values of variables or the threads running at that point.

Step Over

Use the Step Over command when you want to skip debugging a method. If you select this command, the Debugger halts execution on the line following the method call.

For an example of when this command could be useful, imagine that you're using code someone else has written, and you encounter a method call with logic you didn't create. Debugging this method would be almost impossible . So instead of going through each line of code in that method, you could step over the method and go directly to the code you've written.

Step Out

At times, you might need to debug a method, but don't need to go line-by-line into the method itself. In this case, the Step Out command is helpful. When you select this command, the Debugger finishes executing the method without halting and returns to the procedure that called it.

Consider the previous example, in which you use a method written by another developer. If you want to check the values of variables in the method, this command can be helpful. Sometimes, based on the values in the variables, it's easier to find the error- causing code by using this method.

Continue

The reason breakpoints are so useful is because you can set them to halt execution at particular places in your code, depending on your needs. However, after you halt to examine code, you need a command to continue code execution until the next breakpoint. When you select the Continue command, the Debugger resumes code execution until the next breakpoint.

Export Threads

As mentioned earlier in this chapter, threads are a critical part of an infrastructure to be viewed when debugging applications, and saving information on threads can be quite helpful, especially when you have threading problems, such as deadlocks. To do this, you can use the Export Threads command to save or share call stacks of all running threads in a text file.

 <  Day Day Up  >  


BEA WebLogic Workshop 8.1 Kick Start
BEA WebLogic Workshop 8.1 Kick Start: Simplifying Java Web Applications and J2EE
ISBN: 0672326221
EAN: 2147483647
Year: 2004
Pages: 138

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net