Repository navigation
Emit DWARF 5 location and range lists in NativeAOT - #137212
Conversation
With --gdwarf-5 (IlcDwarfVersion=5), ILC emitted version 5 compile units but kept writing DWARF 4 style .debug_loc and .debug_ranges data. DWARF 5 consumers read DW_AT_location/DW_AT_ranges sec_offsets from .debug_loclists/.debug_rnglists, so llvm-dwarfdump reported errors like "unknown rnglists encoding" and "LLE of kind ... not supported". For DWARF 5, write location and range lists to .debug_loclists and .debug_rnglists with the list table header, DW_LLE_start_end/ DW_RLE_start_end entries, ULEB128 expression lengths, and DW_LLE_end_of_list/DW_RLE_end_of_list terminators. Map the new sections for Mach-O as well. Extend the DwarfDump smoke test to dump the loc/range list sections and add a Dwarf5Dump variant that builds the same test with IlcDwarfVersion=5. Co-authored-by: Copilot <[email protected]> Copilot-Session: 890faa16-c536-4f7a-a00a-58d472a8fb1b
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
|
Test failure unrelated: This has only been validated on Linux with |
dsymutil rewrites DWARF 5 location and range lists using DW_LLE_base_addressx/DW_RLE_base_addressx, which index into .debug_addr via the compile unit's DW_AT_addr_base. dsymutil only emits DW_AT_addr_base when the input unit has one, so without it the resulting dSYM had unresolvable base addresses (thousands of llvm-dwarfdump --verify errors). Emit an empty .debug_addr table and reference it from the compile unit when generating DWARF 5. Co-authored-by: Copilot <[email protected]>
When DWARF 5 is enabled, DwarfBuilder writes list table headers and references .debug_loclists, .debug_rnglists and .debug_addr. Create those sections in the Wasm object writer instead of always using the DWARF 4 .debug_loc and .debug_ranges sections. Co-authored-by: Copilot <[email protected]>
|
Validated on macOS 27.2. |
There was a problem hiding this comment.
🔵 Needs a closer look
The DWARF 5 changes need end-to-end validation of Mach-O dsymutil handling of the empty .debug_addr contribution and Wasm linking, since review was source-only and the added smoke tests are Linux-only.
No open issues 🎉
What changed in this PR
This PR updates NativeAOT’s debug-info emission to use DWARF 5 location and range list formats when IlcDwarfVersion=5, while retaining the existing formats for older versions.
Changes:
- Emit DWARF 5 list headers, entries, expression lengths, terminators, and section references.
- Wire the new sections into Unix and WebAssembly object writers, add Mach-O mappings, and emit an empty address table.
- Extend the debug-info smoke test to dump list sections and add a DWARF 5 test variant.
| File | Description |
|---|---|
src/tests/nativeaot/SmokeTests/DwarfDump/Program.cs |
Adds location and range list dumping to the smoke test. |
src/tests/nativeaot/SmokeTests/DwarfDump/Dwarf5Dump.csproj |
Adds a Linux smoke-test variant targeting DWARF 5. |
src/coreclr/tools/Common/Compiler/ObjectWriter/WasmRelocatableObjectWriter.cs |
Selects version-appropriate list sections and emits the address table. |
src/coreclr/tools/Common/Compiler/ObjectWriter/MachObjectWriter.cs |
Maps the new debug sections to Mach-O names. |
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.Aot.cs |
Connects DWARF 5 list and address sections to Unix emission. |
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfNative.cs |
Defines DWARF 5 list entry and terminator constants. |
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs |
Writes version-specific list encodings and section references. |
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfBuilder.cs |
Writes list-table headers, lengths, and an empty address table. |
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs |
Adds a DWARF 5 compile-unit abbreviation with an address-table base. |
Review effort: Balanced
With
--gdwarf-5(IlcDwarfVersion=5), ILC emitted version 5 compile units but kept writing DWARF 4 style.debug_locand.debug_ranges data. DWARF 5 consumers readDW_AT_location/DW_AT_ranges sec_offsetsfrom.debug_loclists/.debug_rnglists, sollvm-dwarfdumpreported errors like"unknown rnglists encoding"and"LLE of kind ... not supported".For DWARF 5, write location and range lists to
.debug_loclistsand.debug_rnglistswith the list table header,DW_LLE_start_end/ DW_RLE_start_endentries, ULEB128 expression lengths, andDW_LLE_end_of_list/DW_RLE_end_of_listterminators. Map the new sections for Mach-O as well.Extend the
DwarfDumpsmoke test to dump the loc/range list sections and add aDwarf5Dumpvariant that builds the same test withIlcDwarfVersion=5.