MPLAB® Code Coverage Details

To view code coverage output, an MPLAB® XC C compiler that supports code coverage must be used with MPLAB X IDE.

Compiler Operation

Code coverage is supported by MPLAB XC C compiler instrumentation. The compiler adds a small amount of code to update flags in RAM to indicate coverage points.

Considerations:

  • If your code fills most of program memory, code coverage may not have enough memory to work.
  • Optimized code can affect how coverage operates. See "Tips and Tricks".

Compiler Operation with No Add-On License

Without the license, the compilers provide a simple ratio of executed coverage points/all coverage points. The compilers don't provide address ranges for the coverage points (bits). So address range overlap due to multiple paths through the code (e.g., if statements) cannot be used to consider coverage.

Compiler Operation with MPLAB Code Coverage

With a license, each coverage point corresponds to several address ranges. So for multiple code paths, ranges covered in at least one coverage point can be considered covered.

MPLAB X IDE Operation

MPLAB X IDE Operation with No Add-On License

MPLAB XC C compilers that do not have the add-on license will display the compiler simple ratio.

MPLAB X IDE Operation with MPLAB Code Coverage

MPLAB XC C compilers that do have the add-on license will display highlighted covered code and percentages of covered code for project files. A report of the coverage may be generated as well.

© 2019 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.