-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
lldb: CXXRecordDecl is incorrectly marked as trivial #73563
Comments
@llvm/issue-subscribers-lldb Author: Haojian Wu (hokein)
Split from the issue https://github.com//issues/72913.
The synthetic CXXRecordDecl AST node in lldb is incorrectly marked as trivial, this will cause incorrect layout calculation. Comments from @Michael137 > Something I noticed that makes this trickier is that RecordDecl::isTrivial() returns true for bar when using LLDBs AST. Whereas with clang it's actually false (which is correct because bar has a default member initialiser, making the default constructor non-trivial). This is important for mustSkipTailPadding, to determine whether to round up the size to alignment or not. So that's a separate bug that needs fixing first |
We'll need DWARF to somehow tell us that a structure has a trivial default constructor. Here are some examples:
In cases 1-2, the default constructor isn't trivial. For explicitly defaulted constructors we have Couldn't find anything in DWARF that would be applicable here. Adding a DWARF attribute for this seems very specific, but since this is important for debuggers to get the data layout right, that's motivation enough? @dwblaikie @adrian-prantl |
Thinking some more about it, DWARF does encode the |
Yeah - so from a derived class you could probably prove which kind of type the base class is - but if you're presented with only the base class, yeah, there's nothing in DWARF that tells you whether a derived class (say if you wanted to create one in the debugger from scratch) should use the tail padding of this type - so that seems like something else to add to the DWARF spec. Like we added But in the interim/for backwards compatibility - would be good to at least use the derived class info to adjust the expectations/properties of the base class, where possible. (does mean a bit of a layering complication where derived class might affect how the base class is built which I'm sure isn't the most elegant thing - and it won't work for every derived class, even - if they need certain alignment, you might not be able to distinguish it from the "don't use tail padding" case (eg: base { int, char }, derived: base {int} - derived will be 12 bytes regardless of whether base is trivial or not) |
The thing to put in DWARF might be something like "should use tail padding" rather than "is trivial" - the latter might have a few too many implications? But perhaps triviality is the better thing to encode - if there's other uses for it in consumers, if it's hard for the consumer to derive that property consistently/correctly. |
Depending on what this looks like this may help with better supporting |
Split from the issue #72913.
The synthetic CXXRecordDecl AST node in lldb is incorrectly marked as trivial, this will cause incorrect layout calculation.
Comments from @Michael137
The text was updated successfully, but these errors were encountered: