NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.
Code Coverage
Contents
- 1 Code Coverage in CCSv4/v5
- 1.1 Enable Code Coverage
- 1.2 Code Coverage Result
- 1.3 Profile Control Points
- 1.4 Code Coverage in CCSv3.3
- 1.5 FAQ
- 1.5.1 Q. In an old code coverage user guide (spru624) I see a limitation that Code Coverage does not work for programs compiled with dwarf debug info. Is this valid anymore?
- 1.5.2 Q. Can I gather Code Coverage results on non-terminating applications (e.g. BIOS-based apps)?
- 1.5.3 Q. How do I view coverage for inline functions?
- 1.5.4 Q. How do I view code coverage for files with the same name in a project?
- 1.5.5 Q. Why do I see multiple entries for the same function in the Function Coverage table?
Code Coverage in CCSv4/v5[edit]
Code Coverage provides coverage data for all functions for the complete run of a program. Note that the code coverage feature describe below is only supported on simulators.
Note: target application must be built with minimal debug option turned on for profiling/Code Coverage to work ([Project Properties]->Tool Settings->Basic Options->Debug model should be set to symdebug:skeletal or symdebug:dwarf). For RTSC project, use 'debug' configuration ... WHOLE_PROGRAM_DEBUG will not work.
Note: Code coverage supports the targets listed in this FAQ entry.
Enable Code Coverage[edit]
- Goto Menu Tools->Profile->Setup Profile Data Collection and select Collect Code Coverage and Exclusive Profile Data
- Click on properties to select the events to be collected along with code coverage.
- Load the application & run.
Code Coverage Result[edit]
- To view the code coverage results, click Menu Tools->Profile->View Code Coverage Results. Function Coverage & Line Coverage window will pop-up.
- To highlight Line coverage info inside the editor window, click on Highlight coverage info in editor icon on the Function Coverage & Line Coverage window.
Profile Control Points[edit]
Profile Control Points enable to collect Function Profiling/Code Coverage for a range or functions. Profile control point works similar to a breakpoint and can be set via Unified Breakpoint Manager (UBM).
- Click on new breakpoint drop-down menu & select Profile Control Point
- Profile Control point menu will pop-up. Need to specify the address & action. Actions are Pause Profiling , Resume Profiling & Terminate Profiling.
- Pause Profiling - Pause collecting profile informations
- Resume Profiling - Resume collecting profile informations
- Terminate Profiling - Stops/Terminate collecting profile informations
Note: Simulator will not halt at these profile control points and Profiler need to be enabled at the beginning.
Code Coverage in CCSv3.3[edit]
Code Coverage is supported on CCSv3.3 as well.
- 2007 TI Developers Conference (Dallas)
- File:CodeCoverageTIDC2007Dallas.pdf
- Topics
- Code Coverage Overview
- Basic usage
- Interpreting the code coverage output
- Batch mode usage
- Topics
- File:CodeCoverageTIDC2007Dallas.pdf
FAQ[edit]
Q. In an old code coverage user guide (spru624) I see a limitation that Code Coverage does not work for programs compiled with dwarf debug info. Is this valid anymore?[edit]
This is a very old document and has been removed from external web. Code coverage indeed works with dwarf debug info and has been the way for years now. The older doc had the limitation as dwarf was just getting introduced at that time.
Q. Can I gather Code Coverage results on non-terminating applications (e.g. BIOS-based apps)?[edit]
Yes (note that BIOS-based applications are "non-terminating" as they simply enter the idle loop when there is nothing that can be run).
- Enable Code Coverage & run the applications till a logical point where you want to stop collecting coverage result.
- Place Profile Control Point for "Terminate Profiling" at that locations.
- Once you cross the profile control point, click Menu Tools->Profile->View Code Coverage Results to view the coverage result.
Alternative method:
- Enable Code Coverage & run the applications till a logical point where you want to stop collecting coverage result.
- Click reset->CPU & click Menu Tools->Profile->View Code Coverage Results to view the coverage result.
Q. How do I view coverage for inline functions?[edit]
Functional coverage for inline functions can be viewed indirectly. When you build a project containing inline functions with the ‘-g’ build option, inline functions behave as normal functions and do not become inline at places where they are called. For example, assume you have a source file called file1.c with the following code:
inline float volume_sphere(float r)
{
return 4.0/3.0 * PI * r * r * r;
}
int foo(...) {
...
volume = volume_sphere(radius);
...
}
If the above source file is build with the ‘-g’ option, then the function volume_sphere would not behave as an inline function. If code coverage was run for this project, the volume_sphere function would be listed in the Function Coverage table (summary worksheet in CCS3.3). However, the function would not behave as an inline function. If the project is built with the Release configuration build option, the functions specified with an inline keyword will retain their inlining behavior.
Q. How do I view code coverage for files with the same name in a project?[edit]
Currently, the Code Coverage tool feature only supports functional coverage for the functions listed in files that have identical names. Line coverage for these files is reported incorrectly. It is recommended not to use files with the same name in a project.
Q. Why do I see multiple entries for the same function in the Function Coverage table?[edit]
A static function is listed in the assembly as many times as it is called. This is valid for static functions declared and defined in the header file. Therefore, functional coverage is listed for each call of the static function