Static Code Analysis in General

Project source file analysis and database generation are divided into two phases: the analysis of individual program modules and the generation of data about project symbol usage. The results of the analysis are saved in database files on the disk, which allows their later use in DAC. The analyzed source is gathered from Editors, or directly from the disk. Files are considered to be C modules if their extension corresponds to one of the extensions defined by Options > Project / File Types.

The analysis can be stopped at any time by clicking the Cancel button in the dialog box showing the operation status. If analysis is canceled, the database will contain incorrect information about project symbol usage.

There are three basic analysis scenarios (menu Start):

Build Project, which pertains to the analysis of all project modules altered after the most recent symbol database build or update. This will optionally check if the header files included in program modules are changed as well.
Rebuild Project
, which pertains to the unconditional analysis of all source modules and the updating of the symbol database.

For each of the scenarios there are two types of symbol analysis module: C-Analysis and Assembler Analysis.

The C-analysis subsystem analyzes source files implemented in the C language, while assembler analysis deals with assembler source files, along with the inline assembler blocks embedded in C source files. Which of the two is to be used on a particular file, DAC determines on the basis of the file's extension. A file is considered a C source module if its extension corresponds to one of the extensions defined in the Options > Project / File types / C source files edit box. A file is considered an assembler source module if its extension corresponds to one of the extensions defined in the Options > Project / File types / Assembler source files edit box.

Static code analysis supports a wide variety of C-dialects and assemblers, developed by various manufacturers for different microcontrollers and microprocessors.

Since Editors retain the original source file line numbers (which are generated while loading the file or during the analysis), the information gathered during the analysis process will be valid for some time, depending on the amount of changes made in the source files.

Static analysis, which is based on the same principles as a compiler or linker, extracts information on symbols (functions, variables, constants, types, macros) from the source code of the project, as well as some other information on the code, for example including header files in modules. This information is stored in the symbol database. At need, other DAC features use the information stored in the symbol database: Editor, Browser, Project Explorer, Graph, Flowchart, Makefile Generator, Documentation Generator.

The project database is located in the folder defined by Options > Project / Database Directory. If the name of the project is PROJECT.DCP, the analysis will produce a PROJECT.ADC file, a PROJECT.ADG file, and a number of .AD files with names that correspond to the project file names. Should any modules have the same name, extensions in the form of .ADn, .Ann, or .nnn will be used; where n is a digit. These files can be transferred to another computer only if the folder structure is the same. Otherwise, it is necessary to repeat the analysis.

The PROJECT.ADC file contains data used for interpreting PROJECT.ADG and .AD files, as well as a list of all header files. Deleting this file makes .AD and .ADG files unusable. Should this happen, the next Start > Build Project will actually build the whole database.

A file with the .ADG extension is generated at the very end of the analysis, and contains projects symbols data. This file will also be regenerated when the Start > Build Project command is executed, but only if at least one .AD file has been changed, or the most recent generation of global data was not completed. If the .ADG file does not exist, DAC will not be able to present the information about global data on program modules different from the current one. If analysis is canceled before a new .ADG file has been generated, DAC will use the old one, so the information based on the database may be outdated.

When upgrading to a new DAC release, you may use the existing project file, but not the existing database. It will be necessary to carry out the Build database command.

Copyright 1993-2017, RistanCASE GmbH