How debuggable is your (compiler-optimised) program?
Abstract#
Source-level debugging of compiled code only works when compilers generate the necessary metadata. Currently, that means it rarely works well, at least in optimising ahead-of-time compilers like LLVM and GCC. I'll give an overview of how compiler-generated metadata enables source-level debugging, the challenges of making it work for optimised code, and our recent work on doing better. Whereas compilers have so far taken a "best-effort" approach with no particular correctness criterion, I'll outline a correctness condition for local variable information that seems to balance the relevant trade-offs. I'll then describe a tool we've built that can use this to mechanically find valid LLVM bugs capturing avoidable losses or corruptions of debug info. A theme will be how the textbook framing of compiler optimisations as "eliminating" code or variables could be more constructively thought of as "residualising" them into debug info; I'll finish with some thoughts on what that could mean for how compilers are built. All this is joint work with J. Ryan Stinnett.