Debugger of Code


VisualMust includes a graphical Java(tm) debugger based on Java Platform Debugger Architecture (JPDA) and Java Debug Interface (JDI).

By setting break points, executing the code step by step, and modifying data dynamically, this tool will allow your applications or applets to be debugged.

Your classpath must include the JDI Library code, which is in JDKx.x/lib/tools.jar, as so far the virtual machine does not take automatically the «tools.jar» library into account.

To start a debugging session, the program should be compiled with the compiler's debugger option.

The current chapter describes each area displayed in the debugger.

Figure 1

Numbered Lines Area BreakPoint Settings Area Code Area Locals Information Area Watch List Area Methods Tree Area Candidate WatchPoint Area Sources Tree Area Classes Tree Area Threads Tree Area ToolBar Status Area Stack-Trace Area Break List Area Monitor Area Application I/O Area

ToolBar Area

The Toolbar allows you to start, stop and step through your lines of code.

 Step Over

Clicking this mini button will cause one source line to be executed. If the source line is a method call, the whole method will be executed, without stepping through the individual method instructions.
 Step Into
Clicking this mini button will cause one source line to be executed. If the source line is a method call, this Step Into command will stop immediately before executing the first statement of the method.
 Step Out
Clicking this mini button will cause one source line to be executed. If the source line is part of a method, the remaining lines of the method will be executed and execution will stop at the caller of the method.
Continuing a Program in the Debugger
From the main window, choose Debug Continue (Ctrl-F5).
The program continues until it reaches a breakpoint or the end of the program.
 Stop
Clicking this mini button will pause the application.
 Resume
Clicking this mini button will resume execution from breakpoint.
 Exit
Clicking this mini button will cause the debugging session to stop.

Status Area

The Status Area and its associated icon will give you information about the state of the virtual machine which is running your application. This virtual machine may be running or stopped. If it is stopped, you will be told why it stopped, because of a break point, a watch point, etc... Thus you will dispose of a resume allowing you to determine in which area to investigate, if you need further information.
Icons - Status Area
  Application is running.
  Application is stopped.

Code Area

The Code Area displays the code being debugged. The current instruction is focussed by a colored line, with a color you chose from the Preferences Panel (see the "Preferences - Editor - Colors" chapter). The tab source code of the current instruction is materialized by a green LED ().

Numbered Lines Area

If you have chosen to see this area through the Preferences Panel (see the "Preferences - Editor - Options" chapter), it will contain the line number associated to the source code.

BreakPoint Settings Area

Breakpoints are orders you may stick into the code at specific points. During the program execution, whenever the Java virtual machine encounters them, it will pause the program, allowing you to check on the value of the data. The virtual machine being stopped, you may investigate, at your convenience. Once you have investigated, eventually modified data, you may start the virtual machine again to keep on running your application.

This area allows to you to set break points. When setting breakpoints, two cases may occur : either the source code is automatically loaded by VisualMust when the class is being loaded by the virtual machine, or the source code has been loaded by you before a debugging session or while a debugging session, but the class is not loaded yet.

1) The class is available and loaded : VisualMust is therefore able to know which lines are candidate to accept a break point. These lines are materialized by a green dot (). You may set break points by clicking on these green dots, the break point will then be represented by a red dot (). It may be removed by clicking the dot again.

2) The class is not loaded yet : In this case, VisualMust is not able to show the lines candidate to a break point. It will let you set break points anywhere in the BreakPoint Settings Area. These break points are not guaranteed as being valid, so they may be rejected by the virtual machine when the class is loaded. They are materialized by a yellow dot ().

Setting a break point will cause it to be added or removed from the Break List Area. Each break point will be kept from one session to another, even if you quit VisualMust.
If you want the source code to be either automatically loaded or not, see the "Preferences - Editor - Debugger" chapter.

When starting a debugging session, VisualMust will generate an automatic break point at the entry point of your program, according to the Always stop at entry point program option.

Methods Tree Area

This area contains a hierarchy of classes and methods associated to the source code. Clicking on a class or a method will cause the source code to be displayed in the Code Area.

Candidate WatchPoint Area

Watchpoints are orders you may stick on class variables (fields). During the program execution, whenever the Java virtual machine uses these fields, it will pause the program, allowing you to check on the value of the data. The virtual machine being stopped, you may investigate, at your convenience. Once you have investigated, eventually modified data, you may start the virtual machine again to keep on running your application.

This area contains all the fields associated to the source code, candidate to be set as watch points. Clicking a field will cause it to be added or removed from the Watch List Area. See Figure 3.

Sources Tree Area

This area contains the list of source codes, according to the source path defined in the Preferences Panel (see the "Preferences - Editor - Debugger" chapter). Clicking an item will cause the source code to be loaded and/or visualized in the Code Area. See Figure 2.

Classes Tree Area

This area contains the list of loaded classes. Clicking an item will cause the source code associated to the class to be loaded and/or visualized in the Code Area. See Figure 4.

Threads Tree Area

This area contains the list of threads that your application has created during runtime. Clicking a thread will cause the Stack Trace Area and Locals Information Area to be changed if required, according to the new thread. See Figure 6.

Stack-Trace Area

This area shows the trace or stack for different classes, methods and positions. The Stack - Trace Area lists the method calls that have started, but have not completed execution, since the program began running. Each item lists the index, class name, method, followed by the position (i.e. the line of the source code).
Usually, the index 1 shows the break point being processed. Clicking another item will cause the source code to be automatically shown in the Code Area, if available. See Figure 2.

Locals Information Area

This area contains the list of available local fields defined in the current method. For each variable, the Locals Information Area displays the variable type, name and value. When you pause the execution of your program, double clicking on the Value column allows you to modify data for this field and then continue execution with the new value in place. See Figure 5.

Break List Area

This area summarizes all break points that are currently set in the source code. Clicking an item will cause the source code to be automatically shown in the Code Area. See Figure 6. Breakpoints are materialized in the Breakpoint Settings Area by a red dot (). They may be removed by clicking the dot.

Watch List Area

This area summarizes all watch points. When clicking the Access and Change checkboxes, you will be able to stipulate whether you want the watch point to be executed on a data fetch, an update or both. You may remove a watch point by unchecking the Access and Change checkboxes, or unchecking the Candidate WatchPoint Area. Clicking on the Value column allows you to modify data for this field, if accessible. See Figure 3.

Monitor Area

This area allows to enter a very simple expression of which you want to know value. An expression may be the name of a field, the name of a field followed by an operator and other fields conform to the Java language. For example, if you have a field defined in your program as :
        int myInt
the simplest expression is myInt.
If you enter myInt in the Add Expression To Monitor field, the value of myInteger will be displayed.
Another valid expression could be :
        myInt = myInt + 10

The AutoExec checkbox, if checked, will cause this expression to be re-executed automatically.

You can also examine variables and evaluate expressions that you select in the Code Area by highlighting the Code Area expression and using the right mouse button.
See Figure 4.

Application I/O Area

This area is considered as a console. It receives outputs from the program. Through this area, you may type information from the keyboard to the application.See Figure 7.

Figure 2


Figure 3


Figure 4


Figure 5


Figure 6


Figure 7


Figure 8


Figure 9