Stream: git-cranelift

Topic: cranelift / Issue #350 DWARF line table support


view this post on Zulip GitHub (Feb 28 2020 at 23:24):

alexcrichton transferred Issue #350:

DWARF line table support may be a good way to get started with the broader topic of producing debug info, as it's relatively straightforward, and quite valuable.

Briefly surveying the landscape, the three main options appear to be:

(There is also the dwarf crate has rudimentary support for writing, though not yet writing .debug_line sections. Judging by this comment, it seems no longer maintained, in favor of gimli.)

Regardless of how we implement it, the code for consuming cretonne IR and emitting DWARF should be in a new crate, as other users of the cretonne-codegen crate won't need it. It will need to emit the binary data for the section, plus relocation records telling the linker where to fix up program addresses.

The first step is to write a minimal .debug_info section, containing a DW_TAG_compile_unit, and a DW_TAG_subprogram entry for each function. Chapter 2 "General Description" of the dwarf spec defines the overall structure of these. I also recommend either the dwarfdump utility and/or readelf --debug-dump=info,lines for examining DWARF output from other compilers to get a sense of what this needs to look like. Then, we can implement the line table. Section 6.2 "Line Number Information" defines the line table format. I'll flesh out these steps more when we're ready; right now I'm just sketching out the major areas that would be covered.


Last updated: Dec 23 2024 at 14:03 UTC