Main Content

Create Polyspace Analysis Configuration Based on Android Builds

You can run a Polyspace® analysis and check for bugs or prove absence of run-time errors in C/C++ code in Android® applications. The most efficient approach to analyze Android applications is to create Polyspace analysis modules based on the existing modularization in your source code. You can then analyze a relatively smaller individual module instead of the entire codebase.

This topic describes in brief the steps for creating a Polyspace analysis module based on the modularization in the Android codebase.

Prerequisites

This topic assumes that you are familiar with building an Android application. For more information on:

The topic also assumes that your Android repository contains a list of modules specified in a file. The file is typically named .repo/project.list.

Step 1: Export JSON Compilation Database

Generate and export a compilation database file corresponding to the Android build.

  1. Open a terminal and navigate to the root of your Android repository.

  2. Enter these or equivalent commands to generate a CCDB file:

    source build/envsetup.sh
    lunch <targetDeviceName>
    export SOONG_GEN_COMPDB=1
    m nothing  
    Here, <targetDeviceName> is the name of the target for which you are building. The CCDB file compile_commands.json is generated in a folder such as <rootPath>/out/soong/development/ide/compdb/, where <rootPath> is relative to the root path of the repository.

Step 2: Create Polyspace Analysis Module

Create Polyspace analysis modules corresponding to the modules listed in your Android repository.

To create the Polyspace analysis modules, run the polyspace-configure command with the CCDB file and the file with the list of Android repo modules as argument. Use one of these approaches:

  • Generate one Polyspace options file per module:

    polyspace-configure -module-list <fileWithModuleList> -compilation-database <ccdbFile> -output-options-path <optionFilesPath>
    This command generates one Polyspace options file per module listed in the file <fileWithModuleList> (see Prerequisites). The sources and compilation options for the module are extracted from the CCDB file <ccdbFile>. The options files are stored in the folder specified by <optionFilesPath> and each options file is named <moduleFolder>.psopts after the module folder name <moduleFolder>.

  • Generate one Polyspace project file (.psprjx file) per module:

    polyspace-configure -module-list <fileWithModuleList> -compilation-database <ccdbFile> -output-platform-project <projectWorkspace>
    This command generates one Polyspace project per module listed in the file <fileWithModuleList>. The sources and compilation options for the module are extracted from the CCDB file <ccdbFile>. The projects are linked from the workspace <projectWorkspace> and each project file is named <moduleFolder>.psprjx after the module folder name <moduleFolde>.

Step 3: Run Polyspace Analysis on Module

Run a Polyspace analysis on a module using the corresponding options file or project:

  1. Build the module so that any file that is generated during build is available for the Polyspace analysis.

  2. Run Polyspace Bug Finder™ or Polyspace Code Prover™ on the module using the corresponding project or options file. For more information, see:

See Also