Overview of Code Coverage with optimized programs
When programmers are building applications, they tend to envision the program logic in terms of the high-level language in which they plan to do the coding. The completed source code is translated by a compiler into machine instructions, which are then normally stored in a library as an executable load module. During execution of the module, it can be difficult to tell whether the program was written in COBOL, Assembler, PL/I, or some other language. One of the primary functions of Code Coverage is to map those compiler-generated machine instructions back to the high-level language of the source code in order to identify which parts of the application have been executed during testing.
When Code Coverage collects data during program testing, it uses information obtained from the compiler to relate the machine instructions back to their corresponding source lines. If a non- optimizing compiler was used, there is typically a one-to-one relationship between machine
instructions and source lines. The output from an optimizing compiler, however, may lack that one- to-one correspondence between source and machine code. For this reason, when Code Coverage data is collected for a program that has been compiled with an optimizing compiler, it can sometimes seem as though the results don't make sense. The following sections explain why this happens and the ways in which Code Coverage attempts to clarify those results.