-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. #92328
Merged
ZequanWu
merged 4 commits into
llvm:main
from
ZequanWu:reapply-delay-definition-die-search
May 28, 2024
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d6de8d9
Reapply [lldb][DWARF] Delay struct/class/union definition DIE searchi…
ZequanWu 2172c66
Fix tests failure on MacOS by query SymbolFileDWARFDebugMap first to …
ZequanWu a2442a2
Remove checking for foreward declaration attr and apply https://githu…
ZequanWu 10b74de
format: tab -> spaces
ZequanWu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
397 changes: 218 additions & 179 deletions
397
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
Large diffs are not rendered by default.
Oops, something went wrong.
197 changes: 88 additions & 109 deletions
197
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
lldb/test/Shell/SymbolFile/DWARF/delayed-definition-die-searching.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Test definition DIE searching is delayed until complete type is required. | ||
|
||
# UNSUPPORTED: system-windows | ||
|
||
# RUN: split-file %s %t | ||
# RUN: %clangxx_host %t/main.cpp %t/t1_def.cpp -gdwarf -o %t.out | ||
# RUN: %lldb -b %t.out -s %t/lldb.cmd | FileCheck %s | ||
|
||
# CHECK: (lldb) p v1 | ||
# CHECK: DWARFASTParserClang::ParseTypeFromDWARF{{.*}}DW_TAG_structure_type (DW_TAG_structure_type) name = 't2<t1>' | ||
# CHECK: DWARFASTParserClang::ParseTypeFromDWARF{{.*}}DW_TAG_structure_type (DW_TAG_structure_type) name = 't1' | ||
# CHECK: DW_TAG_structure_type (DW_TAG_structure_type) 't2<t1>' resolving forward declaration... | ||
# CHECK: (t2<t1>) {} | ||
# CHECK: (lldb) p v2 | ||
# CHECK: DWARFASTParserClang::ParseTypeFromDWARF{{.*}}DW_TAG_structure_type (DW_TAG_structure_type) name = 't1' | ||
# CHECK: DW_TAG_structure_type (DW_TAG_structure_type) 't1' resolving forward declaration... | ||
|
||
#--- lldb.cmd | ||
log enable dwarf comp | ||
p v1 | ||
p v2 | ||
|
||
#--- main.cpp | ||
template<typename T> | ||
struct t2 { | ||
}; | ||
struct t1; | ||
t2<t1> v1; // this CU doesn't have definition DIE for t1, but only declaration DIE for it. | ||
int main() { | ||
} | ||
|
||
#--- t1_def.cpp | ||
struct t1 { // this CU contains definition DIE for t1. | ||
int x; | ||
}; | ||
t1 v2; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could you elaborate on why this wasn't necessary before? We're now mixing CompilerType's (which originate from different ASTContext's) in the same map, which might not be a problem (since we do this for
UniqueDWARFASTTypeMap
already, whoseType
s can also originate from different context's) but I would still like to understand it.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.
TL;DR: This is because this change let
UniqueDWARFASTTypeMap
to cache created Type from declaration DIE. Before this, it was only used for caching Type created from definition DIE. AndUniqueDWARFASTTypeMap
is shared among allSymbolFileDWARF
s belongs to oneSymbolFileDWARFDebugMap
, so shouldm_forward_decl_compiler_type_to_die
which interacts with it.Here's an example with debug map used:
The declaration DIE for
bar
is in foo.o and the definition DIE is in main.o.ParseStructureLikeDIE
was firstly asked to parse the declaration DIE.Before, it will always find the definition DIE in main.o and insert the CompilerType to definition DIE to
m_forward_decl_compiler_type_to_die
which belongs to SymbolFileDWARF(main.o). WhenTypeSystemClang::CompleteTagDecl
wants to completebar
, it asksSymbolFileDWARFDebugMap::CompleteType
to complete, which iterates all its SymbolFileDWARF(main.o, foo.o) and check if the any of them has the compiler type in their maps:llvm-project/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
Lines 808 to 812 in 9144553
bar
's compiler type exists in symbol file(main.o)'s map which also has the definition DIE as value, the type completion will success.If I don't add the fix, we have [bar's compiler type -> bar's declaration DIE] in foo.o's map. When searching for definition DIE, we found that in main.o. Because we have already created its Type from declaration, the
UniqueDWARFASTTypeMap
will find the entry. Then it updates the entry to points to the definition DIE. It updates main.o'sm_forward_decl_compiler_type_to_die
to pointing to the definition DIE, which is wrong, since there's no such entry in main.o's map. It should update foo.o's map. The result is thatSymbolFileDWARFDebugMap::CompleteType
find bar's compiler type exists in foo.o and ask foo.o's symbol file to complete it, but it only has declaration DIE.The fix is to share one
m_forward_decl_compiler_type_to_die
among oneSymbolFileDWARFDebugMap
. With this, when creating compiler type to declaration DIE in the map or updating an entry to point to a definition DIE, we are operating in the same map.