Collecting and Viewing Data

This section demonstrates data visualization by using an example.

To collect and view data for data visualization:

  1. Create a DSC project with the source code shown below.
    Listing: Sample source code used for data visualization
    #include <stdio.h>
    
    
    #include <stdlib.h>
    
    
    
    #define SIZE 10
    
    
    
    #define NO_PRINT
    
    
    
    // prototypes                    
    
    
    
    void swap(int *a, int *b);
    
    
    
    void print_array(int arr[], int length);
    
    
    
    int i = 0; 
    
    
    
    long j = 0;
    
    
    
    int arr[SIZE] = { 4, 6, 7, 1, 2, 3, 4, 12, 4, 5 };
    
    
    
    int main(void) {
    
    
    
        #ifndef NO_PRINT
    
    
           printf("\n\n\n======================================\n");
    
           printf("======================================\n\n");
    
           print_array(arr, SIZE);
    
    
        #endif
    
    
    for (i = 0; i < SIZE - 1; i++)
    
    
        for (j = i; j < SIZE; j++)
    
            if (arr[i] > arr[j])
    
                swap(&arr[i], &arr[j]);
    
    
    #ifndef NO_PRINT
    
    
        print_array(arr, SIZE);
    
    
        printf("\n\n... program done.\n");
    
    
    #endif
    
    
    
      return (0);
    
    
    
    }
    
    
    
    void print_array(int arr[], int length) {
    
    
    
        int i;
    
    
    
        printf("Array = ");
    
    
    
        for (i = 0; i < length; i++) {
    
    
    
            printf("%d ", arr[i]);
    
    
    
        }
    
    
        printf("\n");
    
    
    
    }
    
    
    
    void swap(int *a, int *b) {
    
    
    
       int c = *a;
    
    
    
       *a = *b;
    
    
    
       *b = c;
    
    
    
    }
    
  2. Save and build your project.
  3. Debug the project.
  4. Set data analysispoints.
    1. Open the Variables view. Right-click and select the Add Global Variables option from the context menu.

      The Add Globals dialog box appears.

    2. Select all variables Farr, Fi, Fj and click OK.
    3. Select Fi and select Add Visualization > Add Data Visualization.

      The Add Data Visualization dialog box appears.

    4. Accept the default settings and click OK.
    5. Select Fj, right-click and select View Memory from the context menu.

      The Memory view appears with memory renderings opened.

    6. Right-click the selected cell in the Memory view, and select the Format option from the context menu.

      The Format dialog box appears.

      Figure 1. Format Dialog Box
      Format Dialog Box
    7. Select Column Size as 2 and click OK.
    8. Right-click again in the Memory view on the cell that displays the required address (that is the address of the Fj variable in the Variables view) and select Add Visualization > Add Data Visualization from the context menu.

      The Add Data Visualization dialog box appears.

    9. Select the size of the memory cell as 4 bytes in the Size drop-down list.
    10. Click OK to add the memory data analysispoint to the Analysispoints view.
  5. Set the register analysispoint.
    1. Open the Registers view.
    2. Expand Core Registers > A1 , right-click, and select Add Visualization > Add Data Visualization.
      Figure 2. Registers View
      Registers View

      The Add Data Visualization dialog box appears.

    3. Accept the default settings and click OK.
  6. Open the Analysispoints view and see data and register analysis points that you have set.
  7. Set data visualization breakpoints.
    1. Set a breakpoint on the line swap(&arr[i], &arr[j]);.
    2. Right-click the breakpoint and select Breakpoint Properties from the context menu.

      The Properties dialog box appears.

    3. Click New under Available Actions group to add a new resume action.

      The New Breakpoint Action dialog box appears.

      Figure 3. New Breakpoint Action Dialog Box
      New Breakpoint Action Dialog Box
    4. Type a name for the new resume action, and select Action type as Resume Action.
    5. Keep 0 seconds in the Resume after textbox and click OK.

      The resume action appears in the Available actions table in the Properties dialog box.

    6. Click Attach to attach the resume action with the breakpoint.
    7. Set another breakpoint on the line return 0; with no action attached to the breakpoint.
  8. Resume the application.

    As the application runs and reaches the second breakpoint, the Data Visualization page opens automatically. It displays the last values in a SWT chart read for each visualization analysispoint.

  9. Terminate the application.

    The Software Analysis view opens and populates with a new result set. Only Trace , Data Visualization and Log are visible. The Data Visualization chart populates with the full set of collected values.

    Note: The sampled data can also be seen as a data trace, with Data Read events for memory data and Profile Counters events for variable and register values.
  10. Open the Trace Data viewer.

    The Trace Data viewer contains the same data.

  11. Select another metric for the x-axis, for example, Fj and view results related to it.
    Note: The metric versus time is displayed as lines with symbols, while metric versus metric is displayed as symbols only.

For more information, refer Data Trace Import Dialog Box.