Debugging a Program With dbx

Graphing an Array

Before you can graph an array, you need to follow these preliminary steps:

  1. Load a program into the Debugging window.

    Choose Debug New Program to load your program. If the program was previously loaded in the current Sun WorkShop session, choose the program from the program list in the Debug menu.

  2. Set at least one breakpoint in the program.

    You can set a single breakpoint at the end of the program or you can set one or more at points of interest in your program.

  3. Run your program.

    When the program stops at the breakpoint, decide which array you want to examine.

Now you can graph the array. Sun WorkShop provides multiple ways to graph an array through Sun WorkShop:

From the Debugging window. You can enter an array in the Expression text field and choose Data Graph Expression or you can select an array in a text editor and choose Data Graph Selected in the Debugging window.

From the Data Display window. You can choose the Graph command from the Data menu or from the identical pop-up menu (right-click to open the pop-up). If the array in the Data Display window can be graphed, the Graph command is active.

From the Data Graph window. You can choose Graph New, enter an array name in the Expression text field in the Data Graph: New window and click Graph.

If you click the Replace current graph button, the new graph replaces the current one. Otherwise, a new Data Graph window is opened.

From the dbx Commands window. You can display a Data Graph directly from the dbx command line with the vitem command (you must have opened the Dbx Commands window from Sun WorkShop):


(dbx) vitem -new array-expr

array-expr specifies the array expression to be displayed.