We describe the implementation of the masking Modified Condition/Decision Coverage (MC/DC) support in GCC 14, a powerful structural coverage metric with wide industry adoption for safety critical applications. By analyzing the structure of Boolean expressions with Binary Decision Diagrams we can observe the key property of MC/DC, the power to independently affect the outcome, and map to the edges of the Control Flow Graph. This mapping can be translated to a few bitwise instructions and enables GCC to instrument programs to efficiently observe and record when conditions have been taken and have an independent effect on the outcome of a decision. By analyzing the BDD rather than the program syntax, GCC can measure MC/DC for almost all of its languages with a single language-agnostic implementation, including support for C, C++, D, and Rust.
翻译:我们描述了GCC 14中掩码式改进条件/判定覆盖(MC/DC)支持的实现,这是一种在安全关键应用领域广泛采用的强大结构覆盖度量方法。通过使用二叉决策图分析布尔表达式的结构,我们可以观察到MC/DC的关键特性——独立影响决策结果的能力,并将其映射到控制流图的边。这种映射可转换为少量位运算指令,使GCC能够通过插桩程序来高效观测和记录条件何时被执行,并独立影响决策结果。通过分析BDD而非程序语法,GCC能够以单一语言无关的实现方式测量几乎所有支持语言的MC/DC,包括对C、C++、D和Rust语言的支持。