Debugging

CodeGuide allows you to debug Applications, Applets and Servlets. It supports breakpoints, single line stepping and the introspection of variables and the object heap. CodeGuide supports debugging with Java 1.1 JDKs as well as debugging of Java 2 JDKs using the JPDA debugger technology.

 

To start the debugger press the Run/Continue debugger button in the toolbar or use the Debug | Run/Continue menu item. Your project will be executed in the same way as it would be when running it. However the execution will be somewhat slower. As soon as you start the debugger CodeGuide will pop up the debug browser which allows you to introspect the state of your project and which contains buttons to control the debugger.

 

To stop the execution of the program press the Stop button in the toolbar or select Debug | Stop. To suspend the execution of the program press the Suspend button in the debug browser toolbar or use Debug | Suspend. To continue execution again select Debug | Run/Continue or press the Run/Continue debugger button again.

 

 

Breakpoints and stepping

You can set breakpoints in your program. To do this use the mouse to click twice in the editor bar at the right or select Debug | Toggle breakpoint. To clear all breakpoints use Debug | Clear all breakpoints. Note that breakpoints in a file will not be cleared as soon as it is closed. When the program passes the line of a breakpoint the execution is suspended. The line is highlighted with a red bar. Afterwards you can use the step buttons to step through the code line by line.

 

 

 

Debug browser

The debug browser allows you to introspect the state of your program when it is suspended. It contains three sections: The current scope, the Threads and the Classes. The current scope contains all local variables in the method where the execution has suspended. If a variable contains a reference to an object you can also show the fields of this object with their values. If a breakpoint has been hit all variables available at the breakpoint line will be visible. As you step through the code the current scope will change.

 

 

The classes section displays all loaded classes in all packages and all static fields with their values for each class. The threads section displays all existing threads. The current thread - i.e. the thread which stopped at a breakpoint - is marked by a red flash. You can change the current thread by double-clicking on another thread. For each thread the stack trace is shown. For each frame in the stack trace all visible local variables with their values are shown. If a variable contains a reference to an object you can also show the fields of this object with their values. You can recursively browse the heap this way. In addition you can view the content of arrays.

 

Note that it is only possible to use the debug browser while the program being debugged is suspended because the content of the browser is rapidly changing when the program is running.

 

 

Watches

The debug browser also shows user defined watches. These are variables or fields whose value are automatically shown if they are in scope. To add watch use Debug | Add Watch. You are then prompted to enter the name of a variable or field. You can also use the context menu in the debug browser or in the editor to add a given entry to the watches list. Watches can also be expressions. These may contain field accesses using '.' and array accesses using '[]'.

 

 

Step exclusion

You can exclude certain packages from stepping. The debugger will not step into code which is defined in these packages. By default the debugger does not step into packages of the Java core API (java, javax, sun, sunw, com.sun). Use Preferences | Debugging to define the excluded packages.