-
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
Changes from 1 commit
fa3c96b
288b5f7
1dbde10
8344a98
9694e94
fb5bce0
85c2c42
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 |
|---|---|---|
|
|
@@ -134,7 +134,9 @@ bool TypeQuery::ContextMatches( | |
| if (ctx == ctx_end) | ||
| return false; // Pattern too long. | ||
|
|
||
| if (ctx->kind == CompilerContextKind::Namespace && ctx->name.IsEmpty()) { | ||
| if ((ctx->kind & CompilerContextKind::Namespace) == | ||
|
||
| CompilerContextKind::Namespace && | ||
| ctx->name.IsEmpty()) { | ||
| // We're matching an anonymous namespace. These are optional, so we check | ||
| // if the pattern expects an anonymous namespace. | ||
| if (pat->name.IsEmpty() && (pat->kind & CompilerContextKind::Namespace) == | ||
|
|
@@ -164,7 +166,9 @@ bool TypeQuery::ContextMatches( | |
| auto should_skip = [this](const CompilerContext &ctx) { | ||
| if (ctx.kind == CompilerContextKind::Module) | ||
| return GetIgnoreModules(); | ||
| if (ctx.kind == CompilerContextKind::Namespace && ctx.name.IsEmpty()) | ||
| if ((ctx.kind & CompilerContextKind::Namespace) == | ||
| CompilerContextKind::Namespace && | ||
Michael137 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ctx.name.IsEmpty()) | ||
| return !GetStrictNamespaces(); | ||
| return false; | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,18 @@ | ||||
| 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 | ||||
|
||||
| # RUN: split-file %s %t |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| // clang-format off | ||
| // REQUIRES: target-windows | ||
|
|
||
| // Test namespace lookup. | ||
| // RUN: %build --nodefaultlib -o %t.exe -- %s | ||
| // RUN: %lldb -f %t.exe -s \ | ||
| // RUN: %p/Inputs/namespace-access.lldbinit 2>&1 | FileCheck %s | ||
|
|
||
| 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); | ||
| } | ||
|
|
||
|
|
||
|
|
||
| // 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 |
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.
Actually,
SymbolFileNativePDB::BuildParentMap()already does the tpi stream iteration and it's called at NativePDB plugin initial setup. We could just cache the those base names there instead of iterating it the second time.