@dblaikie suggested I ask this here.
I am wondering what combinations of DWARF4/DWARF5 are valid.
- Monolithic DWARF4 – Monolithic DWARF5. No issues, valid.
- Split DWARF4 – Monolithic DWARF 5. In theory can be? Although both share .debug_addr section and that is different between DWARF4 where it’s a GNU extension, and DWARF5. Trying that combination with toy example llvm-dwarfdump wasn’t able to output it correctly. Didn’t really dig further.
- Monolithic DWARF4 – Split DWARF 5. No issues, valid.
- Split DWARF4 – Split DWARF 5. Not valid. If nothing else due to DWP can’t handle both. I think.
Am I missing anything?
Background for this I am adding support to BOLT to handle mix mode, and plan is to support 1) and 3).
I believe the only limitation is that DWP can’t support mixing v4 and v5. So non-split v4 + split v5 or split v4 + non-split v5 are valid.
The dumper might not dump .debug_addr correctly - but I think that’s just a dumper problem, it shouldn’t be an issue for consumers.
Consumers really only need to read DWARF starting at the .debug_info section - and not reading any part of DWARF that’s not referenced (transitively) from there. But dumpers want to look at sections regardless of whether they’ve parsed the referencing sections, etc. In which case sections without headers (many v4 sections) there’s a fair bit of guesswork in the part of the parser.
llvm-dwarfdump makes a few assumptions like that - most often by looking at the version of the first unit in .debug_info and using that to determine how to parse all the contributions in other sections. More correct would be to only start at
.debug_info and only dump things reachable via references from there.
All of that said - I’m not sure there’s too many folks out there using Split DWARF, I wouldn’t stress it too much - if there’s some combination someone eventually comes across they can always add support for it. (but, yeah, nice to implement all the combinations to ensure there’s not some feature struggle - where someone doesn’t end up using some features (BOLT, Split DWARF, DWARFv5, whatever it is) because of an incompatibility)
Thanks for follow up.
I think for now I’ll stick to the original plan. If someone needs dwarf4 split dwarf + DWARF 5, we can revisit. BOLT relies on DWARFLibrary to parse the debug info, so if llvm-dwarfdump has issues with accessing debug_info correctly we will probably have issues within bolt also.