At the End of the Program Execution

When the instrumented program is tested, the coverage data is written out at the end of the program execution. This is the default behavior and does not require any action of the user.

The Testwell CTC++ run-time library, when it was called along with the execution of the instrumented program, had registered itself to the C run-time system with the atexit() service. When the program is about to end, the C run-time system gives a testimonial call to the run-time library, and so it can do the execution counters saving just before the program ends. In this arrangement, everything takes place automatically. No changes to the source code are needed.

On Windows, the Testwell CTC++ run-time library is a DLL and the automatic coverage data writing is associated with the event when Windows calls the DLL's DllMain() function with the DLL_PROCESS_DETACH reason. But conceptually the arrangement is roughly the same as with the atexit() service.

In situations, where the program does not end (e.g. it is a process that runs forever), or where codeph() is not available (e.g. in some embedded target cases), or when the program does not end normally (e.g. crash), this approach will not work.