Main Content

Source Code in Polyspace Platform User Interface

This topic focuses on the Polyspace® Platform user interface. To learn about the equivalent pane in the Polyspace desktop user interface, see Source Code in Polyspace Desktop User Interface.

The Source Code pane shows the source code with the results highlighted with specific colors and icons. For more information, see Code Prover Result and Source Code Colors.

Source Code pane showing a red finding.

Placing your cursor over a result displays a tooltip that provides range information for variables, operands, function parameters, and return values.

Examine Source Code

On the Source Code pane, if you right-click a text string, the context menu provides options to examine your code. For example, right-click the global variable PowerLevel:

Right-click context menu for PowerLevel global variable in the Source Code pane.

Use the following options to examine and navigate through your code:

  • Search "PowerLevel" in Current Source File — List occurrences of the string within the current source file in the Code Search pane.

  • Search "PowerLevel" in All Source Files — List occurrences of the string within all source files in the Code Search pane.

  • Search For All References — List all references in the Code Search pane. The software supports this feature for global and local variables, functions, types, and classes.

  • Go To Definition — Go to the line of code that contains the definition of PowerLevel. The software supports this feature for global and local variables, functions, types, and classes. If the definition is not available to Polyspace, selecting the option takes you to the function declaration.

  • Go To Line — Open the Go To Line dialog box. If you specify a line number and click Enter, the software displays the specified line of code.

Expand Macros

You can view the contents of source code macros in the source code view. A code information bar displays a macro icon Macro M icon. to identify source code lines with macros.

Unexpanded macro in the Source Code pane.

Select the icon to display the contents of macros on that line in a box.

Expanded macro in the Source Code pane.

To display the normal source code again, click the arrow icon that replaces the macro icon.

To display or hide the content of all macros:

  1. Right-click anywhere on the source.

  2. From the context menu, select either Expand All Macros or Collapse All Macros.

Note

  1. The Result Details pane also allows you to view the contents of a macro if the check you select lies within a macro.

  2. You cannot expand OSEK API macros in the Source Code pane.

View Variable Ranges

Place your cursor over a check to view range information for variables, operands, function parameters, and return values.

If a tooltip is available for a keyword or identifier on the Source Code pane, Polyspace:

  • Uses solid underlining for the keyword or identifier if it is associated with a check.

  • Uses dashed underlining for the keyword or identifier if it is not associated with a check.

Tooltip for the local variable beta.

The range displayed is the same as the range that the software calculates during verification (or includes the range if rounded during display). For instance, for floating point variables, the tooltips show the variable range using the following rules:

  • The range appears as a collection of values, for instance 1.0 or 2.0 or NaN, or an interval [1.0 .. 2.0].

  • The displayed range includes the actual variable range. For instance, the range [1.0 .. 2.0] on a variable indicates that the variable cannot have the value 0.9999 or 2.0001.

    However, the displayed range can also include additional values because of approximation.

  • Constants are displayed using either fixed point (1.0, -2.0, etc.) or scientific format when it improves readability (1.0E+10, -1.2E-20, etc.).

  • The tooltips clearly indicate which values are shown with rounding. For instance, the value 1.0 does not involve rounding but 1.2345... shows a variable that is displayed with rounding towards zero.

    When rounded, at least 5 significant digits are displayed.

Manage Multiple Files

You can view multiple source files in the Source Code pane as separate tabs.

On the Source Code pane toolbar, right-click a view.

Context menu for files in the Source Code pane.

From the Source Code pane context menu, you can:

  • Close - Close the currently selected source file. You can also use the χ button to close tabs.

  • Close All Except <filename> - Close all source files except the currently selected file.

  • Close All - Close all source files.

  • Sub-Tile - Split the Source window vertically or horizontally to display the selected source file alongside another file. Select the option Single to revert the Source Code pane back to a one tile view.