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
debug/dwarf: StructField.ByteSize not set #21093
Comments
I don't think this is a bug in debug/dwarf, and probably isn't a bug at all. DW_TAG_member can optionally have a DW_AT_byte_size, but it's not required. From dwarf4:
I'm not sure what circumstances would cause that to happen in any language, but it can't in Go AFAIK. So I think the short story is you should be looking at f.Type.Size(). |
Not important here, but to answer the question: the size of a data member differs from the size of the data member's type for a C/C++ bitfield. |
@randall77 : anything further here? |
@heschik I think we should either add a comment to debug/dwarf, or better modify the code so that it does the StructField.ByteSize = Type.Size() for you. |
Change https://golang.org/cl/71671 mentions this issue: |
The fields StructField.ByteSize is not set. (ByteOffset is set.)
Demonstration:
Build with
go build
and run it with no args. It reads its own DWARF info and prints out the info for all the struct fields.Start of output:
I think this is a bug with debug/dwarf, not the DWARF writer in the toolchain. I get the same behavior when reading DWARF from a C binary. (Or perhaps the C writer has the same issue?)
ByteSize might be kind of useful (or is .Type.Size() the recommended fallback instead?). At the very least, we should document that it isn't provided.
@heschik @derekparker
The text was updated successfully, but these errors were encountered: