Static code analysis in IAR’s Atmel AVR32 tools

April 29, 2015 // By Graham Prophet
IAR Systems has added its static analysis add-on product C-STAT as well as stack usage analysis and parallel build for shortened build times, in the latest updates to its IAR Embedded Workbench for Atmel AVR32 embedded development toolchain.

The new version, 4.30, introduces the C-STAT add-on product for completely integrated static code analysis. Also added is stack usage analysis and shortened build times through parallel build.

Static analysis finds potential issues in code by doing an analysis on the source code level. Such errors as memory leaks, access violations, arithmetic errors and array and string overruns can cause security issues and affect the performance and quality of a product. By using static analysis, developers can identify these errors early and minimise their impact on the finished product and the project timeline. In addition to raising the code quality, the analysis can aid alignment with industry coding standards. C-STAT is a static analysis tool that checks compliance with rules as defined by the coding standards MISRA C:2004, MISRA C++:2008 and MISRA C:2012 , as well as hundreds of rules based on, for example, CWE (the Common Weakness Enumeration) and CERT C/C++ . Users can easily select which rule-set and which individual rules to check the code against, and the analysis results are provided directly in the IAR Embedded Workbench IDE. C-STAT is available as an add-on product.

The new version also adds stack usage analysis. The stack is a fundamental property of an embedded system and a proper setup of the stack is essential to system stability and reliability. However, calculating the stack space is notoriously hard, making worst case maximum stack depth very useful information as it greatly simplifies estimates of how much stack an application will need. With stack usage analysis enabled in IAR Embedded Workbench, a stack usage section will be added to the linker map file with listings of the maximum stack depth for each call graph root. The analysis process can be customised to take into account such constructs as calls via function pointers and recursion. The output can optionally be generated in XML format for post processing.

In the compiler, parallel build has