JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 9.2p0 CONFIDENTIAL CodeSecure Inc
C and C++


Using CodeSonar With CodeVisionAVR

The cvavr compiler model models the behavior of a build carried out with CodeVisionAVR.

The process for constructing a CodeSonar project based on a CodeVisionAVR build differs somewhat to that for other tools. In particular, CodeSonar does not observe the CodeVisionAVR build directly: instead, the cvavr compiler model is applied to the CodeVisionAVR project file



Overview

The cvavr compiler model models the behavior of a build carried out with CodeVisionAVR.

The process for constructing a CodeSonar project based on a CodeVisionAVR build differs somewhat to that for other tools. In particular, CodeSonar does not observe the CodeVisionAVR build directly: instead, the cvavr compiler model is applied to the CodeVisionAVR project file.

We supply special executable cvavr-null to manage this application. To accumulate CodeSonar project components based on CodeVisionAVR project file P.prj, you will have CodeSonar observe the execution of command:

cvavr-null -f P.prj

Note that CodeVisionAVR projects have the same .prj suffixes as the project files generated by CodeSonar, even though they are not otherwise related. To avoid confusion, you may wish to keep the two kinds of .prj file in different locations, add a prefix such as cs_ to your CodeSonar pfiles-name, or choose some other distinguishing mechanism.

Using The Model

To build a CodeSonar project based on CodeVisionAVR project file path/to/projectdir/my_codevision_project.prj, do the following.

  1. If the CodeSonar installation bin directory is not already in your PATH, add it now.
  2. Build your CodeVisionAVR project as normal.
  3. Build/analyze a CodeSonar project based on the CodeVisionAVR project file.
    Command Line
    cd path/to/projectdir
    codesonar analyze csproject localhost:7340 cvavr-null.exe -f my_codevision_project.prj
    Windows Build Wizard
    1. Work through screens 1 and 2 of the Windows build wizard. On screen 2, specify Watch: Everything.
    2. Once you have clicked Record, execute the following in a command prompt.
      cd path/to/projectdir
      cvavr-null.exe -f my_codevision_project.prj
    3. Perform any other builds that you want CodeSonar to observe, then Finalize.

Note: you may experience false positive Null Pointer Dereference warnings if your code includes low-valued but non-null pointers. To eliminate these warnings, set a lower null pointer threshold by adding following rule to an appropriate configuration file: either the general template configuration file, or individual general project configuration files for CodeSonar projects based on CodeVisionAVRbuilds.

NULL_POINTER_THRESHOLD = 1

Project File Arguments

The following table lists CodeVisionAVR project file arguments that receive additional treatment in the cvavr compiler model.

Argument Additional Treatment in Model
8BitEnums=val Defines macro _8BIT_ENUMS_=val.
CharIsUnsigned=val Defines macro _UNSIGNED_CHAR_=val.
Chip=val Defines macro _CHIP_VAL_=1, where VAL is the upcased version of val. Depending on val, may also define an additional macro:
  • If val has case-insensitive substring XMEGA, defines macro _ATXMEGA_DEVICE_=1.
  • Otherwise, if val has case-insensitive substring TINY, defines macro _AVR8L_CORE_=1.
  • Otherwise, if val has case-insensitive substring MEGA, defines macro _ENHANCED_CORE_=1.
CPUClock=val Defines macro _MCU_CLOCK_FREQUENCY_=val.
Fnum=feo Specifies front end option feo.
GLCDDisplayIndex=val Defines several macros, where the precise set of macros and values depending on val.
  • For any MemoryModel=val:
    • _GLCD_INTERNAL_FONT_HEIGHT_=8
    • _GLCD_INTERNAL_FONT_WIDTH_=8
  • For MemoryModel=val with 1≤val≤27:
    • _GLCD_MAXX_=xnum where xnum depends on val.
    • _GLCD_MAXY_=ynum where ynum depends on val.
    • _GLCD_CTRL_CONTROLLER_=1 where CTRLR depends on val.
    Where the macros and settings depending on val are as shown in the following table.
    val _GLCD_MAXX_ _GLCD_MAXX_ _GLCD_CTRL_CONTROLLER_
    1≤val≤7 128 64 _GLCD_CTRL_KS0108_=1
    8 84 48 _GLCD_CTRL_PCD8544_=1
    9 320 240 _GLCD_CTRL_S1D13700_=1
    10,11 320 240 _GLCD_CTRL_SED1335_=1
    12,13 122 32 _GLCD_CTRL_SED1520_=1
    14≤val≤25 128 128 _GLCD_CTRL_T6963_=1
    26,27 180 32 _GLCD_CTRL_SED1520_=1
HeapSize=val Defines macro _HEAP_SIZE_=val.
IncludePathnum=path Specifies front end option -Ipath.
IOBitDefinitions=val Defines macro _IO_BITS_DEFINITIONS_=val.
MemoryModel=val Defines a macro, depending on val:
val macro defined
0 _MODEL_TINY_=1
1 _MODEL_SMALL_=1
2 _MODEL_MEDIUM_=1
any other val _MODEL_LARGE_=1
UseFATFS=val Defines macro _USE_FATFS_=val.
Symbolnum=macroname Defines macro macroname=1.

Predefined Macros and Paths

Predefined macros and include paths are listed below.

Paths Always Included The cvavr compiler model specifies front end option -Idir for all dir on the following list that exist on the local system.
  • C:\\Program Files (x86)\\codevisionavr\\inc
  • C:\\Program Files\\codevisionavr\\inc
  • C:\\cvavr\\inc
  • C:\\cvavr2\\inc
  • C:\\cvavreval\\inc
Macros Always Defined
__CODEVISIONAVR__ =2053
__STDC__ =1
_WARNINGS_ON_ =1
Conditionally Defined Macros Additional defined macros and their values depend on the contents of the CodeVisionAVR project file.
Macro Definition Defined when project file contains...
_8BIT_ENUMS_ =val IO8BitEnums=val.
_CHIP_VAL_ =1 Chip=val, where VAL is the upcased version of val.
_ATXMEGA_DEVICE_ =1 Chip=val and val has case-insensitive substring XMEGA.
_AVR8L_CORE_ =1 Chip=val and val has case-insensitive substring TINY (but not XMEGA).
_ENHANCED_CORE_ =1 Chip=val and val has case-insensitive substring MEGA (but not XMEGA or TINY).
_GLCD_CTRL_KS0108_ =1 GLCDDisplayIndex=val for 1≤val≤7.
_GLCD_CTRL_PCD8544_ =1 GLCDDisplayIndex=8.
_GLCD_CTRL_S1D13700_ =1 GLCDDisplayIndex=9.
_GLCD_CTRL_SED1335_ =1 GLCDDisplayIndex=10 or GLCDDisplayIndex=11.
_GLCD_CTRL_SED1520_ =1 GLCDDisplayIndex=val for val∈{12,13,26,27}.
_GLCD_CTRL_T6963_ =1 GLCDDisplayIndex=val for 14≤val≤25.
_GLCD_INTERNAL_FONT_HEIGHT_ =8 GLCDDisplayIndex=val for any val.
_GLCD_INTERNAL_FONT_WIDTH_ =8 GLCDDisplayIndex=val for any val.
_GLCD_MAXX_ =xnum GLCDDisplayIndex=val, where xnum depends on val:
val _GLCD_MAXX_=xnum
1≤val≤7 128
8 84
9,10,11 320
12,13 122
14≤val≤25 128
26,27 180

_GLCD_MAXY_

=ynum GLCDDisplayIndex=val, where ynum depends on val:
val _GLCD_MAXY_=ynum
1≤val≤7 64
8 48
9,10,11 240
12,13 32
14≤val≤25 128
26,27 32
_HEAP_SIZE_ =val HeapSize=val.
_IO_BITS_DEFINITIONS_ =val IOBitDefinitions=val.
_MCU_CLOCK_FREQUENCY_ =val CPUClock=val.
_MODEL_LARGE_ =1 MemoryModel=n for n∉{0,1,2}.
_MODEL_MEDIUM_ =1 MemoryModel=2.
_MODEL_SMALL_ =1 MemoryModel=1.
_MODEL_TINY_ =1 MemoryModel=0.
_UNSIGNED_CHAR_ =val CharIsUnsigned=val.
_USE_FATFS_ =val UseFATFS=val.
Front End Options Always Specified
  • -m32
 

To report problems with this documentation, please visit https://support.codesecure.com/.