-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[LLDB][NativePDB] Allow type lookup in namespaces #149876
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fa3c96b
[LLDB][NativePDB] Allow type lookup in namespaces
Nerixyz 288b5f7
refactor: move basename discovery to `BuildParentMap`
Nerixyz 1dbde10
refactor: convert test to use split-file
Nerixyz 8344a98
refactor: create context in symbol file plugin
Nerixyz 9694e94
fix: add braces to `if`
Nerixyz fb5bce0
fix: comment and move up sorting of map
Nerixyz 85c2c42
fix: assert kind is union
Nerixyz 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -816,10 +816,12 @@ Type::GetTypeScopeAndBasename(llvm::StringRef name) { | |
| case ':': | ||
| if (prev_is_colon && template_depth == 0) { | ||
| llvm::StringRef scope_name = name.slice(name_begin, pos.index() - 1); | ||
| // The itanium demangler uses this string to represent anonymous | ||
| // The demanglers use these strings to represent anonymous | ||
| // namespaces. Convert it to a more language-agnostic form (which is | ||
| // also used in DWARF). | ||
| if (scope_name == "(anonymous namespace)") | ||
| if (scope_name == "(anonymous namespace)" || | ||
| scope_name == "`anonymous namespace'" || | ||
| scope_name == "`anonymous-namespace'") | ||
|
Member
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. if this is how the MS demangler presents anonymous namespaces there's probably some other places where we hardcode this that might need patching up. But that's outside the scope of this PR |
||
| scope_name = ""; | ||
| result.scope.push_back(scope_name); | ||
| name_begin = pos.index() + 1; | ||
|
|
||
135 changes: 135 additions & 0 deletions
135
lldb/test/Shell/SymbolFile/NativePDB/namespace-access.test
This file contains hidden or 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,135 @@ | ||
| # REQUIRES: target-windows | ||
|
|
||
| # Test namespace lookup. | ||
| # RUN: split-file %s %t | ||
| # RUN: %build --nodefaultlib -o %t.exe -- %t/main.cpp | ||
| # RUN: %lldb -f %t.exe -s \ | ||
| # RUN: %t/commands.input 2>&1 | FileCheck %s | ||
|
|
||
| #--- main.cpp | ||
|
|
||
| struct S { | ||
| char a[1]; | ||
| }; | ||
|
|
||
| namespace Outer { | ||
|
|
||
| struct S { | ||
| char a[2]; | ||
| }; | ||
|
|
||
| namespace Inner1 { | ||
| struct S { | ||
| char a[3]; | ||
| }; | ||
|
|
||
| namespace Inner2 { | ||
| struct S { | ||
| char a[4]; | ||
| }; | ||
| } // namespace Inner2 | ||
| } // namespace Inner1 | ||
|
|
||
| namespace Inner2 { | ||
| struct S { | ||
| char a[5]; | ||
| }; | ||
| } // namespace Inner2 | ||
|
|
||
| namespace { | ||
| struct A { | ||
| char a[6]; | ||
| }; | ||
| } // namespace | ||
|
|
||
| } // namespace Outer | ||
|
|
||
| namespace { | ||
| struct A { | ||
| char a[7]; | ||
| }; | ||
| } // namespace | ||
|
|
||
| int main(int argc, char **argv) { | ||
| S s; | ||
| Outer::S os; | ||
| Outer::Inner1::S oi1s; | ||
| Outer::Inner1::Inner2::S oi1i2s; | ||
| Outer::Inner2::S oi2s; | ||
| A a1; | ||
| Outer::A a2; | ||
| return sizeof(s) + sizeof(os) + sizeof(oi1s) + sizeof(oi1i2s) + sizeof(oi2s) + sizeof(a1) + sizeof(a2); | ||
| } | ||
|
|
||
| #--- commands.input | ||
|
|
||
| b main | ||
| r | ||
|
|
||
| type lookup S | ||
| type lookup ::S | ||
| type lookup Outer::S | ||
| type lookup Outer::Inner1::S | ||
| type lookup Inner1::S | ||
| type lookup Outer::Inner1::Inner2::S | ||
| type lookup Inner2::S | ||
| type lookup Outer::Inner2::S | ||
| type lookup Outer::A | ||
| type lookup A | ||
| type lookup ::A | ||
| expr sizeof(S) | ||
| expr sizeof(A) | ||
|
|
||
| quit | ||
|
|
||
| # CHECK: (lldb) type lookup S | ||
| # CHECK: struct S { | ||
| # CHECK: struct S { | ||
| # CHECK: struct S { | ||
| # CHECK: struct S { | ||
| # CHECK: struct S { | ||
| # CHECK: } | ||
| # CHECK-NEXT: (lldb) type lookup ::S | ||
| # CHECK-NEXT: struct S { | ||
| # CHECK-NEXT: char a[1]; | ||
| # CHECK-NEXT: } | ||
| # CHECK-NEXT: (lldb) type lookup Outer::S | ||
| # CHECK-NEXT: struct S { | ||
| # CHECK-NEXT: char a[2]; | ||
| # CHECK-NEXT: } | ||
| # CHECK-NEXT: (lldb) type lookup Outer::Inner1::S | ||
| # CHECK-NEXT: struct S { | ||
| # CHECK-NEXT: char a[3]; | ||
| # CHECK-NEXT: } | ||
| # CHECK-NEXT: (lldb) type lookup Inner1::S | ||
| # CHECK-NEXT: struct S { | ||
| # CHECK-NEXT: char a[3]; | ||
| # CHECK-NEXT: } | ||
| # CHECK-NEXT: (lldb) type lookup Outer::Inner1::Inner2::S | ||
| # CHECK-NEXT: struct S { | ||
| # CHECK-NEXT: char a[4]; | ||
| # CHECK-NEXT: } | ||
| # CHECK-NEXT: (lldb) type lookup Inner2::S | ||
| # CHECK-NEXT: struct S { | ||
| # CHECK: struct S { | ||
| # CHECK: } | ||
| # CHECK-NEXT: (lldb) type lookup Outer::Inner2::S | ||
| # CHECK-NEXT: struct S { | ||
| # CHECK-NEXT: char a[5]; | ||
| # CHECK-NEXT: } | ||
| # CHECK-NEXT: (lldb) type lookup Outer::A | ||
| # CHECK-NEXT: struct A { | ||
| # CHECK-NEXT: char a[6]; | ||
| # CHECK-NEXT: } | ||
| # CHECK-NEXT: (lldb) type lookup A | ||
| # CHECK-NEXT: struct A { | ||
| # CHECK: struct A { | ||
| # CHECK: } | ||
| # CHECK-NEXT: (lldb) type lookup ::A | ||
| # CHECK-NEXT: struct A { | ||
| # CHECK-NEXT: char a[7]; | ||
| # CHECK-NEXT: } | ||
| # CHECK-NEXT: (lldb) expr sizeof(S) | ||
| # CHECK-NEXT: (__size_t) $0 = 1 | ||
| # CHECK-NEXT: (lldb) expr sizeof(A) | ||
| # CHECK-NEXT: (__size_t) $1 = 7 |
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.
Should we check (or assert) that the
m_kindis in fact a union?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.
Although the other accessors don't do this, I added an assertion there. Also looks like there's
name()accessor accesses the wrong union element if the kind is class. In practice, that isn't an issue because all types inherit from the same base classTagRecord.