Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Generate DWARF information #2290
The code in this pull request is the magic that generates DWARF debugging information from the output of the backend and the various debugging analysis passes. It receives information about variable availability and contents; an approximation of the lexical block structure of the program including any inlined-out frames; descriptions of statically-allocated constants; and the linearised code of the program itself. In effect, this is a compiler within a compiler.
The DWARF output generated is comprehensive and could potentially be used for purposes other than debugging (such as program analysis). Remarkably, the output is compatible with GNU toolchains on Linux as well as the LLVM-based toolchain on the latest version of macOS (Mojave), although gdb rather than lldb should be used as the debugger.
It turns out that, by virtue of the optimisations performed by the OCaml compiler and the calling conventions used at runtime, the "phantom let" support and the recent DWARF support for describing call sites both play particularly important roles in achieving a good user experience in the debugger.
This pull request is missing many dependencies at present (to be provided by other GPRs whose upstreaming is in progress) and will no doubt require a certain amount of explanation. I am posting it now so that @bschommer in particular can have a high-level overview of what is going on; this may be useful when reviewing the pull requests for the