Ali-Reza Adl-Tabatabai Source-Level Debugging of Globally Optimized Code Degree Type: Ph.D. in Computer Science Advisor(s): Thomas Gross Graduated: May 1996 Abstract: Compiler optimizations play a crucial role in the performance of modern computer systems. Debugger technology, however, has lagged behind in its support of optimizations. Debugging the unoptimized translation is often impractical, so handling of optimized code by the debugger is necessary. But compiler optimizations make it difficult to provide source- level debugger functionality: When a program is compiled with optimizations, mappings between breakpoints in the source and object code become complicated, and values of variables may be either inaccessible in the runtime state or inconsistent with what the user expects at a breakpoint. Although researchers and implementors have long acknowledged the need for source-level debugging of optimized code, compiler developers have generally avoided implementing this support. Designing a source-level debugger for globally optimized code remains an open problem. This dissertation presents techniques that enable accurate source-level debugging of fully optimized code. These techniques are demonstrated in the context of a compiler that performs a complete set of global scalar optimizations for commonly used source languages such as C. The techniques presented in this dissertation are non-invasive — that is, they do not constrain optimizations in any way and do not require instrumentation of the debugged program. All interactions between the debugger and the user are in terms of the original source text. In general, it is impossible to hide the effects of optimizations from the user and to provide the same interactions as in unoptimized code. The approach presented in this dissertation makes the effects of optimizations transparent whenever possible. Only when optimizations cannot be hidden from the user does the debugger inform the user of the effects of optimizations on the expected execution behavior of the program. This dissertation analyzes in detail the problems caused by scalar optimizations such as partial redundancy elimination, register allocation, instruction scheduling, and many others. This dissertation also presents the low-level algorithms necessary in the compiler and debugger to track the effects of optimizations, and discusses the limitations of the techniques. Finally, this dissertation presents measurements of how often a user is likely to be affected by optimizations during debugging. These measurements are based on an implementation of these techniques in the cmcc compiler, an optimizing C compiler developed as part of this dissertation. Thesis Committee: Thomas Gross (Chair) Bernd Bruegge Peter Lee Susan Graham (UC Berkeley) James Morris, Head, Computer Science Department Raj Reddy Dean, School of Computer Science Keywords: Source-level debugging, compiler optimization, code generation, nonresident variables, endangered variables, suspect variables, noncurrent variables CMU-CS-96-133.pdf (1.13 MB) Copyright Notice