Main Content

Variable Access in Polyspace Desktop User Interface

This topic focuses on the Polyspace® desktop user interface. To learn about the equivalent pane in the Polyspace Access web interface, see Global Variables in Polyspace Access Web Interface (Polyspace Access).

The Variable Access pane displays global variables (and local static variables). For each global variable, the pane lists all functions and tasks performing read/write access on the variables, along with their attributes, such as values, read/write accesses and shared usage.

To open this pane, in the Polyspace desktop user interface, select the button on the Result Details pane.

For each variable and each read/write access, the Variable Access pane contains the relevant attributes. For the variables, the various attributes are listed in this table.

AttributeDescription
Variables

Name of Variable

FileSource file containing variable declaration
Values

Value (or range of values) of variable

This column is empty for pointer variables.

# ReadsNumber of times the variable is read
# WritesNumber of times the variable is written
Written by taskName of tasks writing on variable
Read by taskName of tasks reading variable
Protection

Whether shared variable is protected from concurrent access

(Filled only when Usage column has entry, Shared)

The possible entries in this column are:

  • Critical Section: If variable is accessed in critical section of code

  • Temporal Exclusion: If variable is accessed in mutually exclusive tasks

For more details on these entries, see Multitasking.

UsageShared, if variable is shared between tasks; otherwise, blank
LineLine number of variable declaration
ColColumn number (number of characters from beginning of line) of variable declaration
Data TypeData type of variable (C/C++ data types or structures/classes)

Double-click a variable name to view read/write access operations on the variable. The arrowhead symbols and in the Variable Access pane indicate functions performing read and write access respectively on the global variable. Likewise, tasks performing read and write access are indicated by the symbols and respectively. For further information on tasks, see Tasks (-entry-points).

For access operations on the variables, the various attributes described in the pane are listed in this table.

AttributeDescription
Variables

Names of function (or task) performing read/write access on the variable

Values

Value or range of values of variable in the function or task performing read/write access

This column is empty for pointer variables.

Written by taskOnly for tasks: Name of task performing write access on variable
Read by taskOnly for tasks: Name of task performing read access on variable
LineLine number where function or task accesses variable
ColColumn number where function or task accesses variable
File

Source file containing access operation on variable

If this column contains the name __polyspace__stdstubs.c, it indicates that the variable is accessed inside a Standard Library function.

For example, consider the global variable, SHR2:

The function, Tserver, in the file, tasks1.c, performs two write operations on SHR2. This is indicated in the Variable Access pane by the two instances of Tserver() under the variable, SHR2, marked by . Likewise, the two write accesses by tasks, server1 and server2, are also listed under SHR2 and marked by .

The color scheme for variables in the Variable Access pane is:

  • Black: global variable.

  • Orange: global variable, shared between tasks with no protection against concurrent access.

  • Green: global variable, shared between tasks and protected against concurrent access.

  • Gray: global variable, declared but not used in reachable code.

If a task performs certain operations on a global variable, but the operations are in unreachable code, the tasks are colored gray.

The information about global variables and read/write access operations obtained from the Variable Access pane is called the data dictionary.

You can also perform the following actions from the Variable Access pane.

View Access Graph

View the access operations on a global variable in graphical format using the Variable Access pane. Select the global variable and click .

Here is an example of an access graph:

View Structured Variables

For structured variables, view the individual fields from the Variable Access pane. For example, for the structure, SHR4, the pane displays the fields, SHR4.A and SHR4.B, and the functions performing read/write access on them.

View Operations on Anonymous Variables

You can view operations on anonymous variables. For example, consider this line of code that declares an unnamed union with the variable at an absolute address:

union {char, c; int i; } @0x1234;
When you analyze the preceding code and specify the iar compiler, the unnamed variable at 0x1234 appears in the Variable Access pane with a name that starts with pstanonymous.

View Access Through Global Pointers

View access operations on global variables performed indirectly through global pointers.

If a read/write access on a variable is performed through global pointers, then the access is marked by (read) or (write). Access through pointers is shown like any other direct access.

For instance, in the file, initialisations.c, the variable, arr, is declared as a pointer to the array, tab.

In the file main.c, tab is read in the function, interpolation(), through the global pointer variable, arr. This operation is shown in the Variable Access pane by the icon.

During dynamic memory allocation, memory is allocated directly to a pointer. Because the Values column is populated only for non-pointer variables, you cannot use this column to find the values stored in dynamically allocated memory. Use the Variable Access pane to navigate to dereferences of the pointer on the Source pane. Use the tooltips on this pane to find the values following each pointer dereference.

Show or Hide Callers and Callees

Customize the Variable Access pane to show only the shared variables. On the Variable Access pane toolbar, click the Non-Shared Variables button to show or hide non-shared variables.

Show or Hide Accesses in Unreachable Code

Hide read/write access occurring in unreachable code by clicking the filter button .

Other Features

You cannot see an addressing operation on a global variable or object (in C++) as a read/write operation in the Variable Access pane. For example, consider the following C++ code:

class C0 
{ 
public: 
  C0() {} 
  int get_flag() 
  { 
    volatile int rd; 
    return rd; 
  } 
  ~C0() {} 
private: 
  int a;                /* Never read/written */ 
}; 

C0 c0;                  /* c0 is unreachable */ 

int main() 
{ 
  if (c0.get_flag())    /* Uses address of the method */ 
    { 
      int *ptr = take_addr_of_x(); 
      return 1; 
    } 
  else 
    return 0; 
}

You do not see the method call c0.get_flag() in the Variable Access pane because the call is an addressing operation on the method belonging to the object c0.