C and C++

CodeSonar Library Modeling

CodeSonar ships with library models for for some standard system libraries, and template header patches for others..

library models Function stubs that express the key properties of library functions. CodeSonar demand-loads library models in a manner similar to the system's linker/loader. Any function that is not defined in either the user's program or a library model will be undefined in the project.

The models are located in $CSONAR/codesonar/libmodels/. They are distributed both in source code form (with one .c file for each function) and in CodeSonar's internal representation form. In general, you should not need to edit any of these models. If you do need to edit a model, you will need to rebuild it in order to have your changes reflected in future analyses. Some kinds of models play especially important roles, and are discussed in their own sections:

You can also create your own library models.

  • Authoring Library Models contains instructions for writing models.
  • Library Model Macros and Functions describes existing models and CodeSonar macros that are particularly useful for building further models. It also describes some constructs that you may encounter if you are examining the library models shipped with CodeSonar.
template header patches The library model approach is not tractable for C++ template header libraries. Instead, patch files are applied to the corresponding system library headers during the project build phase, using CodeSonar's source file patching functionality. The patches shipped with CodeSonar are located in $CSONAR/codesonar/libmodels/header_patches/. For more information: