Demo Code and Coverage Colors

For the case \n statement shown in the Demo Code Example page:

  • Both if statement conditions are executed and so are shown in green (covered and executed).
  • Both if statements have evaluated as false and so the following functions are shown in red (covered but not executed).
  • The else of the second if statement applies and so the following function is executed and shown in green.
  • The break of the case statement is shown in yellow or partially covered (covered but partially executed) which seems unexpected as both if statements have executed. To understand what is going on with partial coverage, it is useful to view the Program Memory window.
ProgramMemory_DemoCode.png
Figure 1: Program Memory - Demo Code Example

To see the view shown in the image above:

  • Halt program execution.
  • Open the Program Memory window: Window > Target Memory Views > Program Memory.
  • Place a breakpoint at the second if statement of case \n.
  • Debug until the program pauses at the breakpoint.
  • Step Into once.

In the Program Memory window, you can see the instructions for the else clause and break statement. The compiler has combined the jump back from the function call and the jump out of the case loop into one jump, which associates the break statement with the loop. Therefore, it appears yellow since the if statement condition for true was never executed.

As you can see, viewing Program Memory can help you understand why a line is partially covered (yellow). In general, partially-covered lines can be minimized by writing tests to remove red lines (covered by not executed). Then, the remaining yellow lines can be examined in assembly in the Program Memory window.

© 2024 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.