Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support skeleton and split compilation units #521

Merged
merged 5 commits into from
Jul 6, 2020

Conversation

khuey
Copy link
Contributor

@khuey khuey commented Jul 2, 2020

The gist of this is that in DWARF 5 the DWO id for skeleton/split units lives in the header rather than as an attribute on the CU, so it needs to be parsed and saved somewhere. I chose not to revisit the decision to have a separate CompilationUnitHeader and TypeUnitHeader, and instead replaced UnitHeader with a trait that they both implement. What was previously UnitHeader is now CommonUnitHeader and used in many fewer places. Finally, CompilationUnitHeader grew a CompilationUnitType field that tells us whether we have a conventional, skeleton, or split unit (and what the DWO id is in the latter cases).

@philipc
Copy link
Collaborator

philipc commented Jul 3, 2020

Does your application handle .debug_types? I'm not keen on this extra type parameter for read::dwarf::Unit and I'm wondering how well it works out in practice. Additionally, DWARF5 eliminates .debug_types and moves type units into .debug_info, so this solution doesn't seem to be able to handle that.

Either way, this is going to be a large breaking change, so I'll do a release first.

@khuey
Copy link
Contributor Author

khuey commented Jul 3, 2020

No, I don't handle .debug_types. I've never actually seen it in the wild. gcc has a switch for it but I haven't seen it used.

@philipc
Copy link
Collaborator

philipc commented Jul 4, 2020

In order to handle type units in DWARF 5, type units need to be another variant in a UnitType enum. So there should be a UnitHeadersIter and a UnitHeader that can be used for both .debug_info and .debug_types. Offsets in these will need to be a UnitSectionOffset. I can implement this if you prefer.

@khuey
Copy link
Contributor Author

khuey commented Jul 4, 2020

I'm happy to implement it but I'm not entirely sure what you're suggesting. Do you mean to combine TypeUnitHeader and CompilationUnitHeader (thus leaving type units as a variant in the UnitType enum) and their associated iterator machinery, even for DWARF 4?

@philipc
Copy link
Collaborator

philipc commented Jul 4, 2020

Yes. So Dwarf::units will return an iterator for all units in the .debug_info section, including DWARF 5 type units. And Dwarf::type_units will return an iterator for all units in the .debug_types section. These iterators will have the same type, they will simply be iterating over different section data. The iterator can use the UnitSectionOffset value to determine which section it is as needed DWARF 4.

@khuey
Copy link
Contributor Author

khuey commented Jul 6, 2020

Alright this is rebased on top of #523, plus a few extras now that type units are mixed in.

Copy link
Collaborator

@philipc philipc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@philipc philipc merged commit cb795d6 into gimli-rs:master Jul 6, 2020
@khuey khuey deleted the dwarf5-unit branch July 6, 2020 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants