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

Add a helper for getting the size of a DIE #543

Open
khuey opened this issue Jan 4, 2021 · 1 comment
Open

Add a helper for getting the size of a DIE #543

khuey opened this issue Jan 4, 2021 · 1 comment

Comments

@khuey
Copy link
Contributor

khuey commented Jan 4, 2021

I find myself often typing

die.attr(gimli::DW_AT_byte_size)
    .map(|attr| attr.and_then(|attr| attr.udata_value()).map(|v| v * 8)) // we want the size in bits.
    .or_else(|_| {
        die.attr(gimli::DW_AT_bit_size)
            .map(|attr| attr.and_then(|attr| attr.udata_value()))
    })?

How would you feel about adding that to DebuggingInformationEntry (either directly or on some sort of Ext trait)?

@philipc
Copy link
Collaborator

philipc commented Jan 5, 2021

It would be nice if gimli did something to make it easier to parse these. However, I'm not sure that helper is the correct thing to do.

In DWARF 5 (I haven't checked earlier versions), only base types and data members should have DW_AT_bit_size. Data members in particular are complicated because you need to determine the bit offset too.

Similar I'm sure there's semantic information for other tags and attributes that is specified in the standard but which each user of gimli currently needs to handle themselves.

So what we might need instead is a higher level API that parses all of the attributes for a given tag, as suggested in #82.

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

No branches or pull requests

2 participants