Closed filipnavara closed 2 years ago
Looks good, I can't help in the details as it would require to dig into the specs.
There's couple of things that I need to fix:
DwarfDIE
but not present in dwarfFile.LocationSection
From the specification point of view, in DWARF 4 the structure is pretty simple. You either have start/end/expression entry, or a base address entry (start = MaxValue, end = base address, expression is omitted). I didn't take extra care to represent the base address entry but it's round trip-able at least. With DWARF 5 it gets more complicated because there's a new section to represent the same thing using much more flexible format (eg. using start/length instead of start/end, and other formats). I didn't look much into it but there's a risk that the API shape may need some tweaks if DWARF 5 support is added.
The DWARF 5 format is more friendly to relocatable object files. I didn't realise the need for relocations at first since I prototyped this on Mach-O object files which don't relocate the debug information. Instead the linker produces a map in the linked executable that points to the DWARF information in the original .o files.
Fixed the remaining issues.
Thanks!
One of my experiments uses the LibObjectFile library to generate DWARF debugging info for the .NET NativeAOT compiler. I am missing support for the location list when emitting information about variable locations. Here's a minimal viable implementation to add such support. It's missing error handling at the moment but I am posting it for some early review to get feedback on the general API shape.