Code Coverage Tool Reference Manual

Interpreting the Code Coverage Report
HP Code Coverage Tool Reference Manual for HP Integrity NonStop NS-Series Servers542684-004
7-5
Understanding Color Coding in the Code Coverage
Report
As an example of how color coding can be misleading, consider the following code
sequence. The example shows the color coding that would appear in the report.
In this example, procedure a is called and has an unconditional return in the second
line. Thus, the two lines following the return are uncovered, and you would expect
them to be colored yellow. In fact, only the last line (the closing brace) is yellow. The
compiler did not generate code for the call to c, so there are no blocks on that line.
Accordingly, the call to c is not colored (the same as the two preceding lines), because
codecov believed that the block containing the return statement also included the
call to c, and gave it the same color. The report shows the call to c as covered even
though it actually was not.
For another example, consider the following code sequence:
Now assume that the first assignment was never executed and the second assignment
was executed. As expected, the report shows the first assignment as uncovered
(yellow). However, the report also shows the else statement as yellow, even though it
was executed. That happens because the compiler generated no blocks on the else,
so that line “inherited” the color from the previous line.
These same considerations for individual lines also apply to entire functions. Consider
a sequence consisting of two functions. Assume that the first function was completely
uncovered (pink in the report) and that the second function has portions that were
covered and other portions that were uncovered. You would expect the covered
portions to have no color, and the uncovered portions to be yellow. However, some of
the pink from the first function might appear at the beginning of the second function. In
particular, if comments appear at the beginning of a function, those comments inherit
the color of the previous function (if any) and not the color of the function to which they
apply.
Using the -counts Option
Using the -counts option can help you understand where the basic blocks begin and
end. The -counts option causes block execution counts to be included in the report.
void a() {
return;
c();
}
if (*p=='\001")
answer = DATAL;
else
answer = DATAM;