Main Content

Interpret Errors and Warnings in Polyspace Analysis of AUTOSAR Code

This topic describes a component-based approach to verifying AUTOSAR code with Polyspace. For an integration analysis approach, see Choose Between Component-Based and Integration Analysis of AUTOSAR Code with Polyspace.

To analyze code implementation of AUTOSAR software components, Polyspace® parses the AUTOSAR XML (ARXML) specifications, detects the corresponding code implementation, compiles this code and runs static analysis to detect run-time errors or mismatch between code and specifications. If an error occurs in any of these steps, you do not see analysis results for the software component containing the error. This tutorial shows how to locate and diagnose a class of errors that can occur during parsing of ARXML specifications.

Even if some ARXML specifications have ill-defined elements, the analysis tries to continue further with an ad hoc substitute for those elements, with the assumption that the code implementation might not use those elements. However, for specific types of issues, this substitution is not possible. Therefore, even if the ARXML extraction phase completes with warnings only, the warnings themselves are of two types:

  • Warnings that report issues where the analysis is unable to create a substitute.

    For instance, if an event calls a runnable with an undefined port, the analysis cannot model that event.

  • Warnings that report issues where the analysis proceeds with a degraded substitute.

    For instance, if a data-type used in a runnable or an RTE API function is undefined, the analysis proceeds with a degraded data type.

Example Files

To follow the steps in this tutorial, use the demo files in polyspaceroot\polyspace\examples\doc_cxx\troubleshooting_polyspace_autosar. Here, polyspacroot is the Polyspace installation folder, for instance, C:\Program Files\Polyspace\R2024b.

Overview of File Structure

The demo files consist of a root folder src and two options files:

  • The options file options_ko.txt selects files from the src folder that have deliberately introduced errors.

  • The options file options_ok.txt selects files from the src folder that have the same errors fixed.

The folder src has two subfolders:

  • arxml containing the AUTOSAR XML specifications.

  • impl containing the code implementation of those specifications.

The arxml folder has multiple subfolders. Two of these subfolders, appli and interfaces, have subsubfolders ok and ko at different levels within the folder structure. The ok and ko subsubfolders contain the same set of files, except that the files in ko have deliberately introduced errors.

See File Selections

Open the options files options_ok.txt and options_ko.txt in a text editor and note the files selections in each:

  • The options file options_ok.txt excludes files in ko subfolders at any level of the file hierarchy.

    Note the use of the file selection pattern:

    -not -path '*/ko/*'

  • The options file options_ko.txt excludes files in the ok subfolders at any level of the file hierarchy..

    Note the use of the file selection pattern:

    -not -path '*/ok/*'

In addition, both options files exclude a specific file in the types subfolder named do_not_use_this_arxml_file.arxml using the pattern:

 -path '*/types/*' -not -name 'do_not_use_this_arxml_file.arxml'
The full file selection pattern in the file options_ko.txt requires that all these criteria must be satisfied:

  • The files must not be in a ko subfolder at any level of the hierarchy.

  • The files must not have the extension .arxml.

  • The files must be in one of the folders appli, interfaces, or types (except the file do_not_use_this_arxml_file.arxml).

For more information on file selection patterns, see Select AUTOSAR XML (ARXML) and Code Files for Polyspace Analysis.

Run Analysis

To run the analysis, in a terminal, enter the command:

polyspace-autosar -options-file options_ko.txt
This command assumes that the path polyspaceroot\polyspace\bin is already added to the PATH variable in your operating system. Here, polyspaceroot is the Polyspace installation folder, for instance, C:\Program Files\Polyspace\R2024b. Otherwise, use the full path to the polyspace-autosar command.

Repeat the run with the file options_ok.txt.

Note that the options files use the option -do-not-update-verification to stop the analysis before the code verification phase.

Interpret Warnings

The results of the analysis with options files options_ok.txt and options_ko.txt are stored in the folders project_ok and project_ko respectively.

Navigate to the folder project_ko and open the file psar_project.xhtml in a web browser. You see errors and warnings both in the ARXML parsing and code extraction phase.

For more information on the errors:

  1. Click the icon on the upper left. On the left pane, click Behaviors.

    In the Status for each AUTOSAR Behavior section, note that:

    • The behavior tst003.app.swc001.bhv has errors and warnings in the ARXML parsing phase and code extraction phase.

    • The behavior tst003.app.swc002.bhv does not have errors or warnings.

    You can also filter out behaviors that do not have errors or warnings. On the left pane, in the Behavior Selection section, select behaviors with error-status and click Search.

  2. For further details on the behavior that has errors and warnings, tst003.app.swc001.bhv:

    1. In the section Read AUTOSAR behavior, click the link definition of RTE interface and prove-objective.

    2. Expand the error message at the top. This error illustrates a situation where Polyspace cannot model an event because of an issue in the ARXML specification. In this case, a port is not defined.

    3. On the left pane, in the Function selection section, select all having error or warning and click Search. You see one other error message. Expand the error message. This error illustrates a situation Polyspace can create a model despite an error. In this case, a data type is not defined and the analysis continues with a degraded type.

    Based on the messages, you can locate the exact errors in the ARXML.

    You also see code extraction errors in this behavior. These code extraction errors can be traced back to the issues in the ARXML. If you fix the issues in the ARXML, the code extraction errors are also fixed. You can see a fixed project by running an analysis with the options file options_ok.txt.

See Also

Related Topics