The elapsed execution time can be queried at any breakpoint while debugging a program without modifying the debugger. The time is calculated based on the cache analysis. The number of cache hits and misses can be calculated on the fly from the frequency counters. The elapsed time is then calculated as

where the hit penalty is typically one cycle while the miss penalty is ten cycles [] or even more, depending on the clock rate and the access time of main memory. This time estimate can be converted into seconds by multiplying it by the cycle time. The calculation of hits and misses takes only a short time and can therefore be repeated whenever the program stops at a breakpoint without much overhead. The code performing the calculation is hidden in linked-in library code.
The debugged program has been compiled with full optimizations to avoid time distortion. The compiler was modified to emit debugging information for unoptimized code as well as optimized code. Emitting accurate debugging information for optimized code is a non-trivial task and subject to ongoing research [, , ]. Contrary to debugging unoptimized code, debugging optimized code typically restricts the scope of breakpoints and the displaying of data structures. In the debugging environment described in this paper, a breakpoint set on a source line is approximated as a breakpoint at the beginning of the corresponding basic block when code is optimized. In addition, the value of variables assigned to a register will only be displayed if all live ranges are assigned to the same register []. Register-mapped values may still be inconsistent at times due to global optimizations, such as common subexpression elimination which is a common problem when debugging optimized code.
The fact that optimized code is executed during debugging speeds up the execution over conventional debugging of unoptimized code. The cache simulation, on the other hand, adds to the execution time. A quantitative analysis of the effect of these issues will be given in the measurement section.