Bitwise MC/DC coverage

Code Coverage for C and C++

In some applications, bit-wise operations (&|) can be used instead of Boolean operations (&&||), often due to hardware requirements. By default, Code Coverage considers bit-wise operations as mathematical operations, and not Boolean operations.

To enable coverage of bit-wise operations used as Boolean operations, you must enable the corresponding option in the configuration settings. For MC/DC coverage of these operations, each individual bit represents a condition. In the case of a 16-bit word, each bit is treated as a separate condition.

Because C does not natively support Boolean variables, you must define the bool variable type in the Target Deployment Port (TDP), in Parser Settings > Header adaptation for C.

Note    This section is only used by the attolccp instrumentor. The attolcc1 iinstrumentor does not support MC/DC on bit-wise operations. Therefore, you must ensure that the TDP specifies attolccp as the instrumentor for C by removing the USE_ATTOLCC1 parameter from the TDP Basic settings.

You can use the pragma instruction #pragma attol type_boolean=<myType> to declare which type must be considered as Boolean by the instrumentor.

C++ offers native support for bool type variables, therefore no configuration of the TDP is required.

When the option is enabled, MC/DC coverage is applied to any bit-wise operation that uses only Boolean operands. If one of the operands is not a bool type variable then MC/DC coverage instrumentation is applied to the operation. For example:

int some_bits,few_bits;

bool flag1,flag2,flag3;

if( some_bits & few_bits) .... /* no MCDC coverage */

flag1 = flag2 | flag3;         /* MCDC coverage applied */

flag1 = flag2 | (bool)1;       /* MCDC coverage applied */

flag1 = flag2 | few_bit;       /* no MCDC coverage */


To enable MC/DC coverage on bit-wise operations:

  1. In the Project Explorer, click the Settings button.

  2. Select a node in the Project Explorer pane.

  3. In the Configuration Settings list, select Runtime Analysis > Coverage > Instrumentation Control.

  4. Set the Bitwise as logical setting to Yes.

  5. When you have finished, click OK to validate the changes.

Related Topics

About the Code Coverage Viewer | Selecting Coverage TypesInstrumentation pragmas