-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[lldb][DWARF] Fix adding children to clang type that hasn't started definition. #93839
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
Changes from 1 commit
90cbcf8
d78b4d1
e7fc16e
a09d625
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -13,12 +13,18 @@ | |||
| using namespace lldb_private::dwarf; | ||||
| using namespace lldb_private::plugin::dwarf; | ||||
|
|
||||
| static bool IsStructOrClassTag(llvm::dwarf::Tag Tag) { | ||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we have this function somewhere already. Might be worth checking (possibly even in the llvm headers?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yes in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's here:
lldb_private::plugin::dwarf?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there more tag equality checks around LLDB that could benefit from re-using the following check: There's at least two now. Not sure where we'd put such an API. Perhaps @felipepiovezan or @adrian-prantl have some input on this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, we can probably do it in a different change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's also In And it uses that for the same type of check: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, we definitely need to clean all of these up. |
||||
| return Tag == llvm::dwarf::Tag::DW_TAG_class_type || | ||||
| Tag == llvm::dwarf::Tag::DW_TAG_structure_type; | ||||
| } | ||||
|
|
||||
| UniqueDWARFASTType *UniqueDWARFASTTypeList::Find( | ||||
| const DWARFDIE &die, const lldb_private::Declaration &decl, | ||||
| const int32_t byte_size, bool is_forward_declaration) { | ||||
| for (UniqueDWARFASTType &udt : m_collection) { | ||||
| // Make sure the tags match | ||||
| if (udt.m_die.Tag() == die.Tag()) { | ||||
| if (udt.m_die.Tag() == die.Tag() || (IsStructOrClassTag(udt.m_die.Tag()) && | ||||
| IsStructOrClassTag(die.Tag()))) { | ||||
| // If they are not both definition DIEs or both declaration DIEs, then | ||||
| // don't check for byte size and declaration location, because declaration | ||||
| // DIEs usually don't have those info. | ||||
|
|
@@ -39,7 +45,9 @@ UniqueDWARFASTType *UniqueDWARFASTTypeList::Find( | |||
| while (!done && match && parent_arg_die && parent_pos_die) { | ||||
| const dw_tag_t parent_arg_tag = parent_arg_die.Tag(); | ||||
| const dw_tag_t parent_pos_tag = parent_pos_die.Tag(); | ||||
| if (parent_arg_tag == parent_pos_tag) { | ||||
| if (parent_arg_tag == parent_pos_tag || | ||||
| (IsStructOrClassTag(parent_arg_tag) && | ||||
| IsStructOrClassTag(parent_pos_tag))) { | ||||
| switch (parent_arg_tag) { | ||||
| case DW_TAG_class_type: | ||||
| case DW_TAG_structure_type: | ||||
|
|
||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm in the crashing test case the DWARF itself seems reasonable right? So the comment is a bit misleading.
I like the idea of doing both
TypeSystemClang::StartTagDeclarationDefinitionandTypeSystemClang::CompleteTagDeclarationDefinitioninCompleteRecordType(in fact that's what we're trying to do in https://discourse.llvm.org/t/rfc-lldb-more-reliable-completion-of-record-types/77442#changes-5), but I'd like to understand how we get here after #92328 but not prior. Let me re-read your comment on said PRThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the DWARF is reasonable. I added this just in case of
UniqueDWARFASTTypeMapfailing to find the existing type again for some other reasons in the future... This checks doesn't get trigger for the test you reported before. Maybe it's not necessary, because the following loop also just check for the fully qualified names: https://github.com/llvm/llvm-project/blob/main/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp#L39-L71.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah i see, I'd prefer not to add this then if it's going to be an untested codepath. Perhaps it's worth making this an
lldbassert?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.