Debugging a Program With dbx

Analyzing Visualized Data

There are different ways to update the data being visualized, depending on what you are trying to accomplish. For example, you can update upon demand, at breakpoints, or at specified time intervals. You can observe changes or analyze final results. This section provides several scenarios illustrating different situations.

Two sample programs, dg_fexamp (Fortran) and dg_cexamp (C), are included with WorkShop. These sample programs are used in the following scenarios to illustrate data visualization.

You can also use these programs for practice. They are located in install-dir/SUNWspro/WS5.0/examples/datagrapher, where the default install-dir is /opt. To use the programs, change to this directory and type make, the executable programs are created for you.

Scenario 1: Comparing Different Views of the Same Data

The same data can be graphed multiple times which allows different graph types and different segments of data to be compared.

  1. Load the C or Fortran sample program.

  2. Set a breakpoint at the end of the program.

  3. Start the program, running the program to that breakpoint.

  4. Type bf into the Expressions text field in the Debugging window.

  5. Choose Data Graph Expression, which brings up a Surface graph of both dimensions of the bf array.

  6. Choose Data Graph Expressions again to bring up a duplicate graph.

  7. Click Show Options and select Contour for the graph type. Now you can compare different views of the same data (Surface vs. Contour).

  8. Type bf(1,:) for the Fortran or bf[1][..] for the C example program into the Expression text field.

  9. Now Choose Data Graph Expression to bring up a graph of a section of the data contained in the bf array.

All these different views of the data can now be compared.

Scenario 2: Updating Graphs of Data Automatically.

The updating of a graph can be controlled automatically by turning on the Update at: Program stops option. This feature enables you to make comparisons of data as it changes during the execution of the program.

  1. Load the C or Fortran sample program.

  2. Set a breakpoint at the end of the outer loop of the bf function.

  3. Start the program, running the program to that breakpoint.

  4. Type bf into the Expressions text field.

  5. Choose Data Graph Expression. A graph of the values in the bf array after the first loop iteration appear.

  6. Click Show Options and select Update At: Program stops.

  7. Choose the Go command to cause the execution of several other loop iterations of the program. Each time the program stops at the breakpoint, the graph is updated with the values set in the previous loop iteration.

  8. Utilizing the automatic update feature can save time when an up to date view of the data is desired at each breakpoint.

Scenario 3: Comparing Data Graphs at Different Points in Program

The updating of a graph can also be controlled manually.

  1. Load the C or Fortran example program.

  2. Set a breakpoint at the end of the outer loop of the af function.

  3. Start the program, running the program to that breakpoint.

  4. Type af into the Expression: text field.

  5. Choose Data Graph Expression. A graph of the values in the af array after the first loop iteration appears. Make sure automatic updating is turned off on this graph (the default setting).

  6. Execute another loop iteration of the program using the Go command.

  7. Bring up another graph of the af array choosing Data Graph Expression. This graph contains the data values set in the second iteration of the outer loop.

  8. The data contained in the two loop iterations of the af array can now be compared. Any graph with automatic updating turned off can be used as a reference graph to a graph that is continually being updated automatically or manually.

Scenario 4: Comparing Data Graphs from Different Runs of Same Program

Data graphs persist between different runs of the same program. Graphs from previous runs will not be overwritten unless they are manually updated or automatic updating is turned on.

  1. Load the C or Fortran example program.

  2. Set a breakpoint at the end of the program.

  3. Start the program, running the program to the breakpoint.

  4. Type vec into the expressions text field, and choose Data Graph Expression.

  5. A graph of the vec array appears (as a sine curve).

  6. Now you can edit the program (for example, replace sin with cos). Use fix and continue to recompile the program and continue (click the Fix tool bar button).

  7. Restart the program.

  8. Because automatic updating is turned off, the previous graph does not get updated when the program reaches the breakpoint.

  9. Choose Data Graph Expression (vec is still in the Expressions text field), a graph of the current vec values appear alongside the graph of the previous run.

  10. The data from the two runs can now be compared. The graph of the previous run will only change if it is updated manually using the update button, or if automatic updating is turned on.