Skip to content

Conversation

@filipnavara
Copy link
Contributor

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.

@xoofx
Copy link
Owner

xoofx commented Oct 18, 2022

Looks good, I can't help in the details as it would require to dig into the specs.

@xoofx xoofx added the enhancement New feature or request label Oct 18, 2022
@filipnavara
Copy link
Contributor Author

filipnavara commented Oct 18, 2022

There's couple of things that I need to fix:

  • Emit relocations
  • Add diagnostics for references to location lists that are referenced from 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.

@filipnavara filipnavara marked this pull request as ready for review October 20, 2022 07:19
@filipnavara
Copy link
Contributor Author

Fixed the remaining issues.

@xoofx xoofx merged commit 94a195e into xoofx:master Oct 21, 2022
@xoofx
Copy link
Owner

xoofx commented Oct 21, 2022

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants