[Lldb-commits] [lldb] [lldb][test] Fix D lang mangling test on Windows (PR #94196)
https://github.com/Michael137 approved this pull request. https://github.com/llvm/llvm-project/pull/94196 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [clang][lldb] Don't assert structure layout correctness for layouts provided by LLDB (PR #93809)
Michael137 wrote: > The correct answer here is probably to fix the sizes in the RecordLayout > itself; in particular, the DataSize of the members. That would be ideal, but also means we'd have to reflect the various C++ attributes that affect layout in DWARF. Avoiding adding such language-specific constructs to DWARF is what partly motivated this patch. > We should trust external record layout to the extent that it generates a > valid layout, but if it generates something with overlapping fields, or that > runs outside the claimed bounds of the type, we'll just end up crashing in > IRGen. I assume those things are expressible in DWARF; Yea the idea was that we catch these malformed DWARF representations elsewhere. Not necessarily relying on the record layout layer to tell us about this. Not sure how equipped LLDB currently is in dealing with corrupted DWARF. https://github.com/llvm/llvm-project/pull/93809 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARF] Fix adding children to clang type that hasn't started definition. (PR #93839)
https://github.com/Michael137 approved this pull request. Lets do the cleanup of `IsClassOrStruct` as a follow-up since there seem quite a few places that could benefit from it https://github.com/llvm/llvm-project/pull/93839 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARF] Fix adding children to clang type that hasn't started definition. (PR #93839)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/93839 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARF] Fix adding children to clang type that hasn't started definition. (PR #93839)
@@ -13,12 +13,18 @@ using namespace lldb_private::dwarf; using namespace lldb_private::plugin::dwarf; +static bool IsStructOrClassTag(llvm::dwarf::Tag Tag) { Michael137 wrote: There's also ``` /// Returns true if `tag` is a class_type of structure_type tag. static bool IsClassOrStruct(dw_tag_t tag) { return tag == DW_TAG_class_type || tag == DW_TAG_structure_type; } ``` In `AppleDWARFIndex` FYI https://github.com/llvm/llvm-project/pull/93839 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARF] Fix adding children to clang type that hasn't started definition. (PR #93839)
@@ -2232,6 +2232,10 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE , // For objective C we don't start the definition when the class is // created. TypeSystemClang::StartTagDeclarationDefinition(clang_type); +} else { + assert( + clang_type.IsBeingDefined() && + "The clang type should already start its definition at this point."); Michael137 wrote: Perhaps: ```suggestion "Trying to complete a definition without a prior call to StartTagDeclarationDefinition."); ``` ? https://github.com/llvm/llvm-project/pull/93839 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARF] Fix adding children to clang type that hasn't started definition. (PR #93839)
@@ -13,12 +13,18 @@ using namespace lldb_private::dwarf; using namespace lldb_private::plugin::dwarf; +static bool IsStructOrClassTag(llvm::dwarf::Tag Tag) { Michael137 wrote: Are there more tag equality checks around LLDB that could benefit from re-using the following check: ``` udt.m_die.Tag() == die.Tag() || (IsStructOrClassTag(udt.m_die.Tag()) && IsStructOrClassTag(die.Tag())) ``` 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. https://github.com/llvm/llvm-project/pull/93839 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARF] Fix adding children to clang type that hasn't started definition. (PR #93839)
@@ -2232,6 +2232,11 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE , // For objective C we don't start the definition when the class is // created. TypeSystemClang::StartTagDeclarationDefinition(clang_type); +} else if (!clang_type.IsBeingDefined()) { + // In case of some weired DWARF causing we don't start definition on this + // definition DIE because we failed to find existing clang_type from + // UniqueDWARFASTTypeMap due to overstrict checking. + TypeSystemClang::StartTagDeclarationDefinition(clang_type); Michael137 wrote: 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`? https://github.com/llvm/llvm-project/pull/93839 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARF] Fix adding children to clang type that hasn't started definition. (PR #93839)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/93839 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARF] Fix adding children to clang type that hasn't started definition. (PR #93839)
@@ -2232,6 +2232,11 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE , // For objective C we don't start the definition when the class is // created. TypeSystemClang::StartTagDeclarationDefinition(clang_type); +} else if (!clang_type.IsBeingDefined()) { + // In case of some weired DWARF causing we don't start definition on this + // definition DIE because we failed to find existing clang_type from + // UniqueDWARFASTTypeMap due to overstrict checking. + TypeSystemClang::StartTagDeclarationDefinition(clang_type); Michael137 wrote: 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::StartTagDeclarationDefinition` *and* `TypeSystemClang::CompleteTagDeclarationDefinition` in `CompleteRecordType` (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 https://github.com/llvm/llvm-project/pull/92328 but not prior. Let me re-read your comment https://github.com/llvm/llvm-project/pull/93839 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARF] Fix adding children to clang type that hasn't started definition. (PR #93839)
@@ -13,12 +13,18 @@ using namespace lldb_private::dwarf; using namespace lldb_private::plugin::dwarf; +static bool IsStructOrClassTag(llvm::dwarf::Tag Tag) { Michael137 wrote: Ah yes in `SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext` we have the same kind of check. Maybe one could consolidate those in one API? But might not be worth the churn, so feel free to ignore https://github.com/llvm/llvm-project/pull/93839 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARF] Fix adding children to clang type that hasn't started definition. (PR #93839)
@@ -13,12 +13,18 @@ using namespace lldb_private::dwarf; using namespace lldb_private::plugin::dwarf; +static bool IsStructOrClassTag(llvm::dwarf::Tag Tag) { Michael137 wrote: I think we have this function somewhere already. Might be worth checking (possibly even in the llvm headers?) https://github.com/llvm/llvm-project/pull/93839 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add AddressRange to SB API (PR #93836)
https://github.com/Michael137 approved this pull request. Can confirm that tests pass on my mac now https://github.com/llvm/llvm-project/pull/93836 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix module name tab completion (PR #93458)
Michael137 wrote: Looks like this is breaking the macOS CI: https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake/2534/execution/node/97/log ``` == FAIL: test_shlib_name (TestCompletion.CommandLineCompletionTestCase) -- Traceback (most recent call last): File "/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/API/functionalities/completion/TestCompletion.py", line 926, in test_shlib_name self.completions_match("target symbols add -s ", basenames + paths) File "/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 2219, in completions_match self.assertCountEqual( AssertionError: Element counts were not equal: First has 1, Second has 0: 'dyld' First has 2, Second has 1: 'libc++.1.dylib' First has 1, Second has 0: '/usr/lib/dyld' : List of returned completion is wrong Config=x86_64-/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/bin/clang == FAIL: test_shlib_name (TestCompletion.CommandLineCompletionTestCase) -- Traceback (most recent call last): File "/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 2017, in tearDown Base.tearDown(self) File "/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 1132, in tearDown self.assertEqual(lldb.SBModule.GetNumberAllocatedModules(), 0) AssertionError: 1 != 0 Config=x86_64-/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/bin/clang -- Ran 86 tests in 37.855s FAILED (failures=2, skipped=1) ``` Mind taking a look @labath ? https://github.com/llvm/llvm-project/pull/93458 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [clang][lldb] Don't assert structure layout correctness for layouts provided by LLDB (PR #93809)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/93809 >From 91276f5b2dc05032a285b465c0c8a69541bb25c4 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Thu, 2 May 2024 09:05:01 +0100 Subject: [PATCH 1/3] [clang][lldb] Don't assert structure layout correctness for layouts provided by LLDB This is the outcome of the discussions we had in https://discourse.llvm.org/t/rfc-lldb-handling-no-unique-address-in-lldb/77483 To summarize, LLDB creates AST nodes by parsing debug-info and hands those off to Clang for codegen. There are certain Clang attributes that affect structure layout which are not encoded in DWARF, one of which is `[[no_unique_address]]`. But the affects of such attributes *is* encoded in DWARF in terms of member offsets and sizes. So some of the correctness checks that the `RecordLayoutBuilder` performs aren't really necessary for layouts provided by LLDB since we know that the offsets we get from DWARF are correct (modulo corrupt DWARF). Hence this patch guards those asserts behind the `DebuggerSupport` flag. --- clang/lib/CodeGen/CGRecordLayoutBuilder.cpp | 18 --- .../API/lang/cpp/no_unique_address/Makefile | 3 ++ .../no_unique_address/TestNoUniqueAddress.py | 50 +++ .../API/lang/cpp/no_unique_address/main.cpp | 35 + 4 files changed, 100 insertions(+), 6 deletions(-) create mode 100644 lldb/test/API/lang/cpp/no_unique_address/Makefile create mode 100644 lldb/test/API/lang/cpp/no_unique_address/TestNoUniqueAddress.py create mode 100644 lldb/test/API/lang/cpp/no_unique_address/main.cpp diff --git a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp index 5169be204c14d..32fb032214e28 100644 --- a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp +++ b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp @@ -950,6 +950,9 @@ void CGRecordLowering::calculateZeroInit() { // Verify accumulateBitfields computed the correct storage representations. void CGRecordLowering::checkBitfieldClipping(bool IsNonVirtualBaseType) const { #ifndef NDEBUG + if (Context.getLangOpts().DebuggerSupport) +return; + auto ScissorOffset = calculateTailClippingOffset(IsNonVirtualBaseType); auto Tail = CharUnits::Zero(); for (const auto : Members) { @@ -1008,7 +1011,8 @@ void CGRecordLowering::insertPadding() { if (!Member->Data) continue; CharUnits Offset = Member->Offset; -assert(Offset >= Size); +if (!Context.getLangOpts().DebuggerSupport) + assert(Offset >= Size); // Insert padding if we need to. if (Offset != Size.alignTo(Packed ? CharUnits::One() : getAlignment(Member->Data))) @@ -1138,8 +1142,9 @@ CodeGenTypes::ComputeRecordLayout(const RecordDecl *D, llvm::StructType *Ty) { const ASTRecordLayout = getContext().getASTRecordLayout(D); uint64_t TypeSizeInBits = getContext().toBits(Layout.getSize()); - assert(TypeSizeInBits == getDataLayout().getTypeAllocSizeInBits(Ty) && - "Type size mismatch!"); + if (!Context.getLangOpts().DebuggerSupport) +assert(TypeSizeInBits == getDataLayout().getTypeAllocSizeInBits(Ty) && + "Type size mismatch!"); if (BaseTy) { CharUnits NonVirtualSize = Layout.getNonVirtualSize(); @@ -1147,9 +1152,10 @@ CodeGenTypes::ComputeRecordLayout(const RecordDecl *D, llvm::StructType *Ty) { uint64_t AlignedNonVirtualTypeSizeInBits = getContext().toBits(NonVirtualSize); -assert(AlignedNonVirtualTypeSizeInBits == - getDataLayout().getTypeAllocSizeInBits(BaseTy) && - "Type size mismatch!"); +if (!Context.getLangOpts().DebuggerSupport) + assert(AlignedNonVirtualTypeSizeInBits == + getDataLayout().getTypeAllocSizeInBits(BaseTy) && + "Type size mismatch!"); } // Verify that the LLVM and AST field offsets agree. diff --git a/lldb/test/API/lang/cpp/no_unique_address/Makefile b/lldb/test/API/lang/cpp/no_unique_address/Makefile new file mode 100644 index 0..8b20bcb05 --- /dev/null +++ b/lldb/test/API/lang/cpp/no_unique_address/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp + +include Makefile.rules diff --git a/lldb/test/API/lang/cpp/no_unique_address/TestNoUniqueAddress.py b/lldb/test/API/lang/cpp/no_unique_address/TestNoUniqueAddress.py new file mode 100644 index 0..373bcb9062cde --- /dev/null +++ b/lldb/test/API/lang/cpp/no_unique_address/TestNoUniqueAddress.py @@ -0,0 +1,50 @@ +""" +Test that LLDB correctly handles fields +marked with [[no_unique_address]]. +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class NoUniqueAddressTestCase(TestBase): +def test(self): +self.build() +lldbutil.run_to_source_breakpoint( +self, "return 0", lldb.SBFileSpec("main.cpp", False) +) + +# Qualified/unqualified lookup to templates in namespace +
[Lldb-commits] [clang] [lldb] [clang][lldb] Don't assert structure layout correctness for layouts provided by LLDB (PR #93809)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/93809 >From 91276f5b2dc05032a285b465c0c8a69541bb25c4 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Thu, 2 May 2024 09:05:01 +0100 Subject: [PATCH 1/2] [clang][lldb] Don't assert structure layout correctness for layouts provided by LLDB This is the outcome of the discussions we had in https://discourse.llvm.org/t/rfc-lldb-handling-no-unique-address-in-lldb/77483 To summarize, LLDB creates AST nodes by parsing debug-info and hands those off to Clang for codegen. There are certain Clang attributes that affect structure layout which are not encoded in DWARF, one of which is `[[no_unique_address]]`. But the affects of such attributes *is* encoded in DWARF in terms of member offsets and sizes. So some of the correctness checks that the `RecordLayoutBuilder` performs aren't really necessary for layouts provided by LLDB since we know that the offsets we get from DWARF are correct (modulo corrupt DWARF). Hence this patch guards those asserts behind the `DebuggerSupport` flag. --- clang/lib/CodeGen/CGRecordLayoutBuilder.cpp | 18 --- .../API/lang/cpp/no_unique_address/Makefile | 3 ++ .../no_unique_address/TestNoUniqueAddress.py | 50 +++ .../API/lang/cpp/no_unique_address/main.cpp | 35 + 4 files changed, 100 insertions(+), 6 deletions(-) create mode 100644 lldb/test/API/lang/cpp/no_unique_address/Makefile create mode 100644 lldb/test/API/lang/cpp/no_unique_address/TestNoUniqueAddress.py create mode 100644 lldb/test/API/lang/cpp/no_unique_address/main.cpp diff --git a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp index 5169be204c14d..32fb032214e28 100644 --- a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp +++ b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp @@ -950,6 +950,9 @@ void CGRecordLowering::calculateZeroInit() { // Verify accumulateBitfields computed the correct storage representations. void CGRecordLowering::checkBitfieldClipping(bool IsNonVirtualBaseType) const { #ifndef NDEBUG + if (Context.getLangOpts().DebuggerSupport) +return; + auto ScissorOffset = calculateTailClippingOffset(IsNonVirtualBaseType); auto Tail = CharUnits::Zero(); for (const auto : Members) { @@ -1008,7 +1011,8 @@ void CGRecordLowering::insertPadding() { if (!Member->Data) continue; CharUnits Offset = Member->Offset; -assert(Offset >= Size); +if (!Context.getLangOpts().DebuggerSupport) + assert(Offset >= Size); // Insert padding if we need to. if (Offset != Size.alignTo(Packed ? CharUnits::One() : getAlignment(Member->Data))) @@ -1138,8 +1142,9 @@ CodeGenTypes::ComputeRecordLayout(const RecordDecl *D, llvm::StructType *Ty) { const ASTRecordLayout = getContext().getASTRecordLayout(D); uint64_t TypeSizeInBits = getContext().toBits(Layout.getSize()); - assert(TypeSizeInBits == getDataLayout().getTypeAllocSizeInBits(Ty) && - "Type size mismatch!"); + if (!Context.getLangOpts().DebuggerSupport) +assert(TypeSizeInBits == getDataLayout().getTypeAllocSizeInBits(Ty) && + "Type size mismatch!"); if (BaseTy) { CharUnits NonVirtualSize = Layout.getNonVirtualSize(); @@ -1147,9 +1152,10 @@ CodeGenTypes::ComputeRecordLayout(const RecordDecl *D, llvm::StructType *Ty) { uint64_t AlignedNonVirtualTypeSizeInBits = getContext().toBits(NonVirtualSize); -assert(AlignedNonVirtualTypeSizeInBits == - getDataLayout().getTypeAllocSizeInBits(BaseTy) && - "Type size mismatch!"); +if (!Context.getLangOpts().DebuggerSupport) + assert(AlignedNonVirtualTypeSizeInBits == + getDataLayout().getTypeAllocSizeInBits(BaseTy) && + "Type size mismatch!"); } // Verify that the LLVM and AST field offsets agree. diff --git a/lldb/test/API/lang/cpp/no_unique_address/Makefile b/lldb/test/API/lang/cpp/no_unique_address/Makefile new file mode 100644 index 0..8b20bcb05 --- /dev/null +++ b/lldb/test/API/lang/cpp/no_unique_address/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp + +include Makefile.rules diff --git a/lldb/test/API/lang/cpp/no_unique_address/TestNoUniqueAddress.py b/lldb/test/API/lang/cpp/no_unique_address/TestNoUniqueAddress.py new file mode 100644 index 0..373bcb9062cde --- /dev/null +++ b/lldb/test/API/lang/cpp/no_unique_address/TestNoUniqueAddress.py @@ -0,0 +1,50 @@ +""" +Test that LLDB correctly handles fields +marked with [[no_unique_address]]. +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class NoUniqueAddressTestCase(TestBase): +def test(self): +self.build() +lldbutil.run_to_source_breakpoint( +self, "return 0", lldb.SBFileSpec("main.cpp", False) +) + +# Qualified/unqualified lookup to templates in namespace +
[Lldb-commits] [clang] [lldb] [clang][lldb] Don't assert structure layout correctness for layouts provided by LLDB (PR #93809)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/93809 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [clang][lldb] Don't assert structure layout correctness for layouts provided by LLDB (PR #93809)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/93809 This is the outcome of the discussions we had in https://discourse.llvm.org/t/rfc-lldb-handling-no-unique-address-in-lldb/77483 To summarize, LLDB creates AST nodes by parsing debug-info and hands those off to Clang for codegen. There are certain Clang attributes that affect structure layout which are not encoded in DWARF, one of which is `[[no_unique_address]]`. But the affects of such attributes *is* encoded in DWARF in terms of member offsets and sizes. So some of the correctness checks that the `RecordLayoutBuilder` performs aren't really necessary for layouts provided by LLDB since we know that the offsets we get from DWARF are correct (modulo corrupt DWARF). Hence this patch guards those asserts behind the `DebuggerSupport` flag. This unblocks the libc++ `compressed_pair` refactor in https://github.com/llvm/llvm-project/issues/93069 >From 91276f5b2dc05032a285b465c0c8a69541bb25c4 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Thu, 2 May 2024 09:05:01 +0100 Subject: [PATCH] [clang][lldb] Don't assert structure layout correctness for layouts provided by LLDB This is the outcome of the discussions we had in https://discourse.llvm.org/t/rfc-lldb-handling-no-unique-address-in-lldb/77483 To summarize, LLDB creates AST nodes by parsing debug-info and hands those off to Clang for codegen. There are certain Clang attributes that affect structure layout which are not encoded in DWARF, one of which is `[[no_unique_address]]`. But the affects of such attributes *is* encoded in DWARF in terms of member offsets and sizes. So some of the correctness checks that the `RecordLayoutBuilder` performs aren't really necessary for layouts provided by LLDB since we know that the offsets we get from DWARF are correct (modulo corrupt DWARF). Hence this patch guards those asserts behind the `DebuggerSupport` flag. --- clang/lib/CodeGen/CGRecordLayoutBuilder.cpp | 18 --- .../API/lang/cpp/no_unique_address/Makefile | 3 ++ .../no_unique_address/TestNoUniqueAddress.py | 50 +++ .../API/lang/cpp/no_unique_address/main.cpp | 35 + 4 files changed, 100 insertions(+), 6 deletions(-) create mode 100644 lldb/test/API/lang/cpp/no_unique_address/Makefile create mode 100644 lldb/test/API/lang/cpp/no_unique_address/TestNoUniqueAddress.py create mode 100644 lldb/test/API/lang/cpp/no_unique_address/main.cpp diff --git a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp index 5169be204c14d..32fb032214e28 100644 --- a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp +++ b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp @@ -950,6 +950,9 @@ void CGRecordLowering::calculateZeroInit() { // Verify accumulateBitfields computed the correct storage representations. void CGRecordLowering::checkBitfieldClipping(bool IsNonVirtualBaseType) const { #ifndef NDEBUG + if (Context.getLangOpts().DebuggerSupport) +return; + auto ScissorOffset = calculateTailClippingOffset(IsNonVirtualBaseType); auto Tail = CharUnits::Zero(); for (const auto : Members) { @@ -1008,7 +1011,8 @@ void CGRecordLowering::insertPadding() { if (!Member->Data) continue; CharUnits Offset = Member->Offset; -assert(Offset >= Size); +if (!Context.getLangOpts().DebuggerSupport) + assert(Offset >= Size); // Insert padding if we need to. if (Offset != Size.alignTo(Packed ? CharUnits::One() : getAlignment(Member->Data))) @@ -1138,8 +1142,9 @@ CodeGenTypes::ComputeRecordLayout(const RecordDecl *D, llvm::StructType *Ty) { const ASTRecordLayout = getContext().getASTRecordLayout(D); uint64_t TypeSizeInBits = getContext().toBits(Layout.getSize()); - assert(TypeSizeInBits == getDataLayout().getTypeAllocSizeInBits(Ty) && - "Type size mismatch!"); + if (!Context.getLangOpts().DebuggerSupport) +assert(TypeSizeInBits == getDataLayout().getTypeAllocSizeInBits(Ty) && + "Type size mismatch!"); if (BaseTy) { CharUnits NonVirtualSize = Layout.getNonVirtualSize(); @@ -1147,9 +1152,10 @@ CodeGenTypes::ComputeRecordLayout(const RecordDecl *D, llvm::StructType *Ty) { uint64_t AlignedNonVirtualTypeSizeInBits = getContext().toBits(NonVirtualSize); -assert(AlignedNonVirtualTypeSizeInBits == - getDataLayout().getTypeAllocSizeInBits(BaseTy) && - "Type size mismatch!"); +if (!Context.getLangOpts().DebuggerSupport) + assert(AlignedNonVirtualTypeSizeInBits == + getDataLayout().getTypeAllocSizeInBits(BaseTy) && + "Type size mismatch!"); } // Verify that the LLVM and AST field offsets agree. diff --git a/lldb/test/API/lang/cpp/no_unique_address/Makefile b/lldb/test/API/lang/cpp/no_unique_address/Makefile new file mode 100644 index 0..8b20bcb05 --- /dev/null +++ b/lldb/test/API/lang/cpp/no_unique_address/Makefile @@ -0,0 +1,3 @@
[Lldb-commits] [lldb] 8b600a3 - Revert "Add SBAddressRange and SBAddressRangeList to SB API (#92014)"
Author: Michael Buch Date: 2024-05-30T12:40:05+01:00 New Revision: 8b600a37325bd68c370b00838c9f0a0fda1af6ce URL: https://github.com/llvm/llvm-project/commit/8b600a37325bd68c370b00838c9f0a0fda1af6ce DIFF: https://github.com/llvm/llvm-project/commit/8b600a37325bd68c370b00838c9f0a0fda1af6ce.diff LOG: Revert "Add SBAddressRange and SBAddressRangeList to SB API (#92014)" This reverts commit 42944e4600827738fae868f0df831fb2678be8b4. Added: Modified: lldb/bindings/headers.swig lldb/bindings/interfaces.swig lldb/include/lldb/API/LLDB.h lldb/include/lldb/API/SBAddress.h lldb/include/lldb/API/SBBlock.h lldb/include/lldb/API/SBDefines.h lldb/include/lldb/API/SBFunction.h lldb/include/lldb/API/SBStream.h lldb/include/lldb/API/SBTarget.h lldb/include/lldb/Core/AddressRange.h lldb/include/lldb/Symbol/Block.h lldb/include/lldb/lldb-forward.h lldb/source/API/CMakeLists.txt lldb/source/API/SBBlock.cpp lldb/source/API/SBFunction.cpp lldb/source/Core/AddressRange.cpp lldb/source/Core/CMakeLists.txt lldb/source/Symbol/Block.cpp Removed: lldb/bindings/interface/SBAddressRangeDocstrings.i lldb/bindings/interface/SBAddressRangeExtensions.i lldb/bindings/interface/SBAddressRangeListDocstrings.i lldb/bindings/interface/SBAddressRangeListExtensions.i lldb/include/lldb/API/SBAddressRange.h lldb/include/lldb/API/SBAddressRangeList.h lldb/include/lldb/Core/AddressRangeListImpl.h lldb/source/API/SBAddressRange.cpp lldb/source/API/SBAddressRangeList.cpp lldb/source/Core/AddressRangeListImpl.cpp lldb/test/API/python_api/address_range/Makefile lldb/test/API/python_api/address_range/TestAddressRange.py lldb/test/API/python_api/address_range/main.cpp diff --git a/lldb/bindings/headers.swig b/lldb/bindings/headers.swig index c91504604b6ac..ffdc3c31ec883 100644 --- a/lldb/bindings/headers.swig +++ b/lldb/bindings/headers.swig @@ -8,8 +8,6 @@ %{ #include "lldb/lldb-public.h" #include "lldb/API/SBAddress.h" -#include "lldb/API/SBAddressRange.h" -#include "lldb/API/SBAddressRangeList.h" #include "lldb/API/SBAttachInfo.h" #include "lldb/API/SBBlock.h" #include "lldb/API/SBBreakpoint.h" diff --git a/lldb/bindings/interface/SBAddressRangeDocstrings.i b/lldb/bindings/interface/SBAddressRangeDocstrings.i deleted file mode 100644 index 650195704d73e..0 --- a/lldb/bindings/interface/SBAddressRangeDocstrings.i +++ /dev/null @@ -1,3 +0,0 @@ -%feature("docstring", -"API clients can get address range information." -) lldb::SBAddressRange; diff --git a/lldb/bindings/interface/SBAddressRangeExtensions.i b/lldb/bindings/interface/SBAddressRangeExtensions.i deleted file mode 100644 index 31bcfcb64590b..0 --- a/lldb/bindings/interface/SBAddressRangeExtensions.i +++ /dev/null @@ -1,11 +0,0 @@ -%extend lldb::SBAddressRange { -#ifdef SWIGPYTHON -%pythoncode%{ - def __repr__(self): -import lldb -stream = lldb.SBStream() -self.GetDescription(stream, lldb.target if lldb.target else lldb.SBTarget()) -return stream.GetData() -%} -#endif -} diff --git a/lldb/bindings/interface/SBAddressRangeListDocstrings.i b/lldb/bindings/interface/SBAddressRangeListDocstrings.i deleted file mode 100644 index e4b96b9ca5931..0 --- a/lldb/bindings/interface/SBAddressRangeListDocstrings.i +++ /dev/null @@ -1,3 +0,0 @@ -%feature("docstring", -"Represents a list of :py:class:`SBAddressRange`." -) lldb::SBAddressRangeList; diff --git a/lldb/bindings/interface/SBAddressRangeListExtensions.i b/lldb/bindings/interface/SBAddressRangeListExtensions.i deleted file mode 100644 index e281a84d73d27..0 --- a/lldb/bindings/interface/SBAddressRangeListExtensions.i +++ /dev/null @@ -1,29 +0,0 @@ -%extend lldb::SBAddressRangeList { -#ifdef SWIGPYTHON -%pythoncode%{ -def __len__(self): - '''Return the number of address ranges in a lldb.SBAddressRangeList object.''' - return self.GetSize() - -def __iter__(self): - '''Iterate over all the address ranges in a lldb.SBAddressRangeList object.''' - return lldb_iter(self, 'GetSize', 'GetAddressRangeAtIndex') - -def __getitem__(self, idx): - '''Get the address range at a given index in an lldb.SBAddressRangeList object.''' - if not isinstance(idx, int): -raise TypeError("unsupported index type: %s" % type(idx)) - count = len(self) - if not (-count <= idx < count): -raise IndexError("list index out of range") - idx %= count - return self.GetAddressRangeAtIndex(idx) - -def __repr__(self): - import lldb - stream = lldb.SBStream() - self.GetDescription(stream, lldb.target if lldb.target else lldb.SBTarget()) - return stream.GetData() -%} -#endif -} diff --git a/lldb/bindings/interfaces.swig b/lldb/bindings/interfaces.swig
[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)
Michael137 wrote: I'll revert this for now. Let me know if you need help reproducing the failure https://github.com/llvm/llvm-project/pull/92014 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)
Michael137 wrote: @clayborg this change went in as part of https://github.com/llvm/llvm-project/pull/92328 so i think we can close this now. Though there's a test failure linked to that PR currently, meaning it might have to get reverted. We should keep an eye out for that https://github.com/llvm/llvm-project/pull/91808 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #92328)
Michael137 wrote: Huh this is an interesting one. So it looks like we first parse and insert `struct Inner` into `UniqueDWARFASTTypeMap` as a forward declaration. Then when we search the debug-map for the definition of `Inner`, we find it declared as `class Inner` (note, *class* vs. *struct*...i.e., the DIE tags don't match), and fail to find the entry in said map. So we end up not calling `StartTagDeclarationDefinition` by the time we get to `CompleteType`, and hence we assert. If i hack those to align all is well: ``` (lldb) n Process 61300 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = step over frame #0: 0x0001204bd8f8 liblldb.19.0.0git.dylib`lldb_private::plugin::dwarf::UniqueDWARFASTTypeList::Find(this=0x000107bceb28, die=0x00016fdfa428, decl=0x00016fdf98b0, byte_size=4, is_forward_d eclaration=false) at UniqueDWARFASTType.cpp:21:9 18 const int32_t byte_size, bool is_forward_declaration) { 19 for (UniqueDWARFASTType : m_collection) { 20 // Make sure the tags match -> 21 if (udt.m_die.Tag() == die.Tag()) { 22 // If they are not both definition DIEs or both declaration DIEs, then 23 // don't check for byte size and declaration location, because declaration 24 // DIEs usually don't have those info. Target 0: (lldb) stopped. (lldb) p udt.m_die.Tag() (dw_tag_t) DW_TAG_structure_type (lldb) p die.Tag() (dw_tag_t) DW_TAG_class_type (lldb) p die.m_die->m_tag = (llvm::dwarf::Tag)0x0013 (dw_tag_t) DW_TAG_structure_type (lldb) c Process 61300 resuming (D::Inner &) inner_d = 0x0001400c (j = 68) (lldb) Process 61300 exited with status = 0 (0x) ``` https://github.com/llvm/llvm-project/pull/92328 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [IRInterpreter] Return zero address for missing weak function (PR #93548)
https://github.com/Michael137 approved this pull request. Seems like a reasonable thing to do (as this comment in [LoadAddressResolver ::Resolve](https://github.com/llvm/llvm-project/blob/fd8b2d2046508c027ccf0fffb50d665c8355997a/lldb/source/Expression/IRExecutionUnit.cpp#L758-L761) implies). Might want to hold off from merging in case @jimingham has any input https://github.com/llvm/llvm-project/pull/93548 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #92328)
Michael137 wrote: Unfortunately this breaks `TestCPPAccelerator.py` on the macOS buildbots: https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/4788/execution/node/97/log/ ``` Ran command: "log enable dwarf lookups -f/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/lldb-test-build.noindex/lang/cpp/accelerator-table/TestCPPAccelerator.test_dwarf/dwarf.log" Got output: runCmd: frame variable inner_d Assertion failed: (DD && "queried property of class with no definition"), function data, file DeclCXX.h, line 464. PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. Stack dump: 0. HandleCommand(command = "frame variable inner_d") ``` The stacktrace I got when locally reproducing this: ``` Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libsystem_kernel.dylib 0x18e0a1540 __pthread_kill + 8 1 libsystem_pthread.dylib0x18e0d9bcc pthread_kill + 288 2 libsystem_c.dylib 0x18dfe6964 __abort + 136 3 libsystem_c.dylib 0x18dfe68dc abort + 140 4 libsystem_c.dylib 0x18dfe5bc8 __assert_rtn + 284 5 liblldb.19.0.0git.dylib0x31fd217c0 clang::CXXRecordDecl::data() const + 112 6 liblldb.19.0.0git.dylib0x31fe9cb8c clang::CXXRecordDecl::hasUserDeclaredMoveConstructor() const + 24 7 liblldb.19.0.0git.dylib0x31fe7edf8 lldb_private::TypeSystemClang::CompleteTagDeclarationDefinition(lldb_private::CompilerType const&) + 256 8 liblldb.19.0.0git.dylib0x31fd142a8 DWARFASTParserClang::CompleteRecordType(lldb_private::plugin::dwarf::DWARFDIE const&, lldb_private::Type*, lldb_private::CompilerType&) + 1024 9 liblldb.19.0.0git.dylib0x31fd14f4c DWARFASTParserClang::CompleteTypeFromDWARF(lldb_private::plugin::dwarf::DWARFDIE const&, lldb_private::Type*, lldb_private::CompilerType&) + 316 10 liblldb.19.0.0git.dylib0x31fd9cc78 lldb_private::plugin::dwarf::SymbolFileDWARF::CompleteType(lldb_private::CompilerType&) + 1160 11 liblldb.19.0.0git.dylib0x31fdf3a64 lldb_private::plugin::dwarf::SymbolFileDWARFDebugMap::CompleteType(lldb_private::CompilerType&)::$_0::operator()(lldb_private::plugin::dwarf::SymbolFileDWARF*) const + 72 12 liblldb.19.0.0git.dylib0x31fdf3a10 decltype(std::declval()(std::declval())) std::__1::__invoke[abi:nn180100](lldb_private::plugin::dwarf::SymbolFileDWARFDebugMap::CompleteType(lldb_private::CompilerType&)::$_0&, lldb_private::plugin::dwarf::SymbolFileDWARF*&&) + 36 13 liblldb.19.0.0git.dylib0x31fdf39bc lldb_private::IterationAction std::__1::__invoke_void_return_wrapper::__call[abi:nn180100](lldb_private::plugin::dwarf::SymbolFileDWARFDebugMap::CompleteType(lldb_private::CompilerType&)::$_0&, lldb_private::plugin::dwarf::SymbolFileDWARF*&&) + 32 14 liblldb.19.0.0git.dylib0x31fdf3990 std::__1::__function::__alloc_func, lldb_private::IterationAction (lldb_private::plugin::dwarf::SymbolFileDWARF*)>::operator()[abi:nn180100](lldb_private::plugin::dwarf::SymbolFileDWARF*&&) + 36 15 liblldb.19.0.0git.dylib0x31fdf28a4 std::__1::__function::__func, lldb_private::IterationAction (lldb_private::plugin::dwarf::SymbolFileDWARF*)>::operator()(lldb_private::plugin::dwarf::SymbolFileDWARF*&&) + 36 16 liblldb.19.0.0git.dylib0x31fde1f84 std::__1::__function::__value_func::operator()[abi:nn180100](lldb_private::plugin::dwarf::SymbolFileDWARF*&&) const + 76 17 liblldb.19.0.0git.dylib0x31fde1f2c std::__1::function::operator()(lldb_private::plugin::dwarf::SymbolFileDWARF*) const + 36 18 liblldb.19.0.0git.dylib0x31fdde658 lldb_private::plugin::dwarf::SymbolFileDWARFDebugMap::ForEachSymbolFile(std::__1::function) + 128 19 liblldb.19.0.0git.dylib0x31fdde58c lldb_private::plugin::dwarf::SymbolFileDWARFDebugMap::CompleteType(lldb_private::CompilerType&) + 112 20 liblldb.19.0.0git.dylib0x31fe9f5cc lldb_private::TypeSystemClang::CompleteTagDecl(clang::TagDecl*) + 120 21 liblldb.19.0.0git.dylib0x321364718 lldb_private::ClangExternalASTSourceCallbacks::CompleteType(clang::TagDecl*) + 36 22 liblldb.19.0.0git.dylib0x31fe82b94 GetCompleteQualType(clang::ASTContext*, clang::QualType, bool) + 516 23 liblldb.19.0.0git.dylib0x31fe8e1f4 lldb_private::TypeSystemClang::GetNumChildren(void*, bool, lldb_private::ExecutionContext const*) + 436 24 liblldb.19.0.0git.dylib0x31f2f7f88 lldb_private::CompilerType::GetNumChildren(bool, lldb_private::ExecutionContext const*) const + 144 25 liblldb.19.0.0git.dylib0x31fe8e60c
[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)
Michael137 wrote: FYI, the `TestAddressRange` tests are failing on the macOS buildbots: https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/4764/execution/node/97/log/ ``` == FAIL: test_address_range_print_resolved (TestAddressRange.AddressRangeTestCase) Make sure the SBAddressRange can be printed when resolved. -- Traceback (most recent call last): File "/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/python_api/address_range/TestAddressRange.py", line 186, in test_address_range_print_resolved self.assertRegex(range_str, "^\[0x[0-9a-f]+\-0x[0-9a-f]+\)$") AssertionError: Regex didn't match: '^\\[0x[0-9a-f]+\\-0x[0-9a-f]+\\)$' not found in 'a.out[0x13f70-0x13fa0)' ``` Seems like we just didn't account for the `a.out` prefix here? https://github.com/llvm/llvm-project/pull/92014 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] fe82a3d - Revert "[Support] Remove terminfo dependency (#92865)"
Author: Michael Buch Date: 2024-05-29T16:20:42+01:00 New Revision: fe82a3da36196157c0caa1ef2505186782f750d1 URL: https://github.com/llvm/llvm-project/commit/fe82a3da36196157c0caa1ef2505186782f750d1 DIFF: https://github.com/llvm/llvm-project/commit/fe82a3da36196157c0caa1ef2505186782f750d1.diff LOG: Revert "[Support] Remove terminfo dependency (#92865)" This reverts commit 6bf450c7a60fa62c642e39836566da94bb9bbc91. It breaks LLDB CI: https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/4762/execution/node/97/log/ ``` /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -Wdocumentation -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-deprecated-register -Wno-vla-extension -O3 -DNDEBUG -arch arm64 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -mmacosx-version-min=14.1 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-dead_strip -Wl,-no_warn_duplicate_libraries tools/lldb/unittests/Editline/CMakeFiles/EditlineTests.dir/EditlineTest.cpp.o -o tools/lldb/unittests/Editline/EditlineTests lib/libLLVMSupport.a lib/libllvm_gtest_main.a lib/libllvm_gtest.a lib/liblldbHost.a lib/liblldbUtility.a lib/libLLVMTestingSupport.a /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/libxml2.tbd /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/libedit.tbd lib/liblldbHostMacOSXObjCXX.a lib/liblldbUtility.a -framework Foundation -framework CoreFoundation -framework CoreServices -framework Security lib/libLLVMObject.a lib/libLLVMIRReader.a lib/libLLVMBitReader.a lib/libLLVMAsmParser.a lib/libLLVMCore.a lib/libLLVMRemarks.a lib/libLLVMBitstreamReader.a lib/libLLVMMCParser.a lib/libLLVMMC.a lib/libLLVMDebugInfoCodeView.a lib/libLLVMTextAPI.a lib/libLLVMBinaryFormat.a lib/libLLVMTargetParser.a lib/libllvm_gtest.a lib/libLLVMSupport.a -lm /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/libz.tbd /opt/homebrew/lib/libzstd.dylib lib/libLLVMDemangle.a -lpthread && cd /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/tools/lldb/unittests/Editline && /opt/homebrew/Cellar/cmake/3.28.3/bin/cmake -E make_directory /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/tools/lldb/unittests/Editline/./Inputs ld: Undefined symbols: _setupterm, referenced from: lldb_private::Editline::Editline(char const*, __sFILE*, __sFILE*, __sFILE*, std::__1::recursive_mutex&) in liblldbHost.a[35](Editline.cpp.o) clang: error: linker command failed with exit code 1 (use -v to see invocation) ``` Added: llvm/cmake/modules/FindTerminfo.cmake llvm/utils/gn/build/libs/terminfo/BUILD.gn llvm/utils/gn/build/libs/terminfo/enable.gni Modified: clang/cmake/caches/Fuchsia-stage2.cmake clang/cmake/caches/Fuchsia.cmake clang/cmake/caches/VectorEngine.cmake clang/utils/analyzer/entrypoint.py compiler-rt/cmake/config-ix.cmake compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh compiler-rt/lib/xray/tests/CMakeLists.txt lldb/docs/resources/build.rst lldb/source/Core/CMakeLists.txt llvm/CMakeLists.txt llvm/cmake/config-ix.cmake llvm/cmake/modules/LLVMConfig.cmake.in llvm/docs/ReleaseNotes.rst llvm/include/llvm/Config/config.h.cmake llvm/lib/Support/CMakeLists.txt llvm/lib/Support/Unix/Process.inc llvm/utils/gn/README.rst llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn llvm/utils/gn/secondary/llvm/tools/llvm-config/BUILD.gn utils/bazel/.bazelrc utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h utils/bazel/llvm_configs/config.h.cmake Removed: diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake b/clang/cmake/caches/Fuchsia-stage2.cmake index 66e764968e85ce..d5546e20873b3c 100644 --- a/clang/cmake/caches/Fuchsia-stage2.cmake +++ b/clang/cmake/caches/Fuchsia-stage2.cmake @@ -19,6 +19,7 @@ set(LLVM_ENABLE_LLD ON CACHE BOOL "") set(LLVM_ENABLE_LTO ON CACHE BOOL "") set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ON CACHE BOOL "") set(LLVM_ENABLE_PLUGINS OFF CACHE BOOL "") +set(LLVM_ENABLE_TERMINFO
[Lldb-commits] [clang] [compiler-rt] [lldb] [llvm] [Support] Remove terminfo dependency (PR #92865)
Michael137 wrote: I'm going to revert this for now until since the bots have been red for a while now https://github.com/llvm/llvm-project/pull/92865 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/DWARF] Follow DW_AT_signature when computing type contexts (PR #93675)
https://github.com/Michael137 approved this pull request. https://github.com/llvm/llvm-project/pull/93675 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)
Michael137 wrote: Now that we don't search for the definition DIE when initially parsing a DIE, we could probably move this progress report to when we look for `FindDefinitionTypeForDIE`, which seems to be the most expensive part of the `DWARFASTParser` https://github.com/llvm/llvm-project/pull/91452 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)
Michael137 wrote: @labath baseline for just attaching is approximately `3 s` for LLDB and `2.5 s`. Baselines for attaching *and* stopping at the breakpoint are in the `break only` rows of the table. https://github.com/llvm/llvm-project/pull/91452 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/DWARF] Refactor DWARFDIE::Get{Decl, TypeLookup}Context (PR #93291)
https://github.com/Michael137 approved this pull request. nice! tests also LGTM https://github.com/llvm/llvm-project/pull/93291 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/DWARF] Refactor DWARFDIE::Get{Decl, TypeLookup}Context (PR #93291)
https://github.com/Michael137 approved this pull request. LGTM! (seems like we could probably add unit-tests for this in `lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp`? But not a blocker) https://github.com/llvm/llvm-project/pull/93291 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)
Michael137 wrote: Sorry for the delayed response, just got back from vacation. > What do these numbers include? Is it just the operation it self, or > everything leading up to it as well. > Thanks for doing this. What do these numbers include? Is it just the > operation it self, or everything leading up to it as well. For example, is > "expr var" just the timing of the "expr" command, or attach command as well. The benchmarks include the attach command as well. E.g., `expr var` would be the time it took to attach/stop at a breakpoint in Clang and run `expr`. I'll post the baseline shortly https://github.com/llvm/llvm-project/pull/91452 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Windows] Skip the TestDataFormatterLibcxxChrono test to avoid python crash (PR #92575)
Michael137 wrote: I think we should just fix https://github.com/llvm/llvm-project/issues/92574 since it seems pretty trivial to do with an ifdef https://github.com/llvm/llvm-project/pull/92575 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)
Michael137 wrote: I attached to clang and printed an expression. That resulted in 16801 calls to `Progress::Increment`, all of which I'm guessing translate to event broadcasts. I collected some timing numbers: ``` https://github.com/llvm/llvm-project/assets/14071464/97333f8a-2e35-47c9-8cd0-d610daa077fd;> ``` So across the various scenarios i tested the slowdown is somewhere between 10-90 ms on average. > I'd expect that a one of these operations (parsing/importing one type) would > be pretty fast, and that the whole process takes so long simply because > performing a very large number of these ops. @labath Mostly that's true. Occasionally these operations can take longer if we end up searching for types/functions across multiple object files (especially with https://github.com/apple/llvm-project/pull/8222). We could certainly consider some sort of rate limiting here. Or maybe find a better place to report progress on? > Anyway, if the code is recursive, we might need to do something like we did > for Swift, with one top-level event and callback that updates the details. @JDevlieghere @adrian-prantl are there plans to change the presentation layer to prevent this kind of shadowing in the future? Would be nice if all we needed to do was report progress, and not worry about other progress events in the debugger being in-flight https://github.com/llvm/llvm-project/pull/91452 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #92328)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/92328 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #92328)
@@ -321,6 +326,10 @@ class SymbolFileDWARFDebugMap : public SymbolFileCommon { std::vector m_func_indexes; // Sorted by address std::vector m_glob_indexes; std::map>, OSOInfoSP> m_oso_map; + // A map from CompilerType to the struct/class/union/enum DIE (might be a + // declaration or a definition) that is used to construct it. + llvm::DenseMap + m_forward_decl_compiler_type_to_die; Michael137 wrote: 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, whose `Type`s can also originate from different context's. https://github.com/llvm/llvm-project/pull/92328 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #92328)
@@ -2306,6 +2345,11 @@ bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE , if (!die) return false; + ParsedDWARFTypeAttributes attrs(die); Michael137 wrote: I've been wondering how expensive constructing this object is. On a brief glance it seems to be doing a lot of work, but maybe all of that work is actually not that slow? Do you know why we get here for forward declarations with your patch, but didn't before? https://github.com/llvm/llvm-project/pull/92328 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][TypeSystem][NFCI] Log creation of new TypeSystem instances to expression log (PR #91985)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/91985 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][TypeSystem][NFCI] Log creation of new TypeSystem instances to expression log (PR #91985)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/91985 >From 1ccf935f97b21e0bd87955f3313cb47261d11379 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 13 May 2024 15:34:24 +0100 Subject: [PATCH 1/3] [lldb][TypeSystem][NFCI] Log creation of new TypeSystem instances to expression log We emit `ASTContext` and `TypeSystem` pointers into the `expr` log but there is no easy way (that I know of) to correlate the pointer value back to an easily readible form. This patch simply logs the name of the `TypeSystem` and the associated `ASTContext` into the `expr` channel whenever we create a new `TypeSystemClang`. --- .../TypeSystem/Clang/TypeSystemClang.cpp | 21 +++ .../TypeSystem/Clang/TypeSystemClang.h| 4 +++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index d0033fcd9cdfc..a7b5c55098de2 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -501,6 +501,8 @@ TypeSystemClang::TypeSystemClang(llvm::StringRef name, // The caller didn't pass an ASTContext so create a new one for this // TypeSystemClang. CreateASTContext(); + + LogCreation(); } TypeSystemClang::TypeSystemClang(llvm::StringRef name, @@ -510,6 +512,8 @@ TypeSystemClang::TypeSystemClang(llvm::StringRef name, m_ast_up.reset(_ctxt); GetASTMap().Insert(_ctxt, this); + + LogCreation(); } // Destructor @@ -544,13 +548,16 @@ lldb::TypeSystemSP TypeSystemClang::CreateInstance(lldb::LanguageType language, } } + lldb::TypeSystemSP instance; + if (module) { std::string ast_name = "ASTContext for '" + module->GetFileSpec().GetPath() + "'"; -return std::make_shared(ast_name, triple); +instance = std::make_shared(ast_name, triple); } else if (target && target->IsValid()) -return std::make_shared(*target, triple); - return lldb::TypeSystemSP(); +instance = std::make_shared(*target, triple); + + return instance; } LanguageSet TypeSystemClang::GetSupportedLanguagesForTypes() { @@ -630,7 +637,7 @@ void TypeSystemClang::SetExternalSource( ast.setExternalSource(ast_source_up); } -ASTContext ::getASTContext() { +ASTContext ::getASTContext() const { assert(m_ast_up); return *m_ast_up; } @@ -9750,3 +9757,9 @@ bool TypeSystemClang::SetDeclIsForcefullyCompleted(const clang::TagDecl *td) { metadata->SetIsForcefullyCompleted(); return true; } + +void TypeSystemClang::LogCreation() const { + if (auto *log = GetLog(LLDBLog::Expressions)) +LLDB_LOG(log, "Created new TypeSystem for (ASTContext*){0:x} '{1}'", + (), getDisplayName()); +} diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h index 59ca69622d9e8..6ba2c44c36584 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -162,7 +162,7 @@ class TypeSystemClang : public TypeSystem { llvm::StringRef getDisplayName() const { return m_display_name; } /// Returns the clang::ASTContext instance managed by this TypeSystemClang. - clang::ASTContext (); + clang::ASTContext () const; clang::MangleContext *getMangleContext(); @@ -1166,6 +1166,8 @@ class TypeSystemClang : public TypeSystem { bool IsTypeImpl(lldb::opaque_compiler_type_t type, llvm::function_ref predicate) const; + void LogCreation() const; + // Classes that inherit from TypeSystemClang can see and modify these std::string m_target_triple; std::unique_ptr m_ast_up; >From 8cb97736d9ba9bd2f1a0bc10f96c3ad7b9f9f59f Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 13 May 2024 17:19:21 +0100 Subject: [PATCH 2/3] fixup! revert obsolete changes --- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index a7b5c55098de2..8b9ef98071e68 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -548,16 +548,14 @@ lldb::TypeSystemSP TypeSystemClang::CreateInstance(lldb::LanguageType language, } } - lldb::TypeSystemSP instance; - if (module) { std::string ast_name = "ASTContext for '" + module->GetFileSpec().GetPath() + "'"; -instance = std::make_shared(ast_name, triple); +return std::make_shared(ast_name, triple); } else if (target && target->IsValid()) -instance = std::make_shared(*target, triple); +return std::make_shared(*target, triple); - return instance; + return lldb::TypeSystemSP(); } LanguageSet TypeSystemClang::GetSupportedLanguagesForTypes() {
[Lldb-commits] [lldb] [lldb][ExpressionParser][NFCI] Log pointers as hex (PR #91989)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/91989 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][ExpressionParser][NFCI] Log pointers as hex (PR #91989)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/91989 >From 1fba045db76f51a2dbd9a2a3cb9879858b5b653e Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 13 May 2024 14:50:07 +0100 Subject: [PATCH 1/3] [lldb][ExpressionParser][NFCI] Log pointers as hex This ensures that we log pointers as lower-case hex. E.g., instead of: ``` LayoutRecordType on (ASTContext*)0x00010E78D600 'scratch ASTContext' for (RecordDecl*)0x00010E797 ``` we now log: ``` ``` --- .../Clang/ClangASTImporter.cpp| 48 +-- .../ExpressionParser/Clang/ClangASTSource.cpp | 44 - 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp index 30b50df79da90..2889bef26c3bc 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp @@ -313,8 +313,8 @@ CompilerType ClangASTImporter::DeportType(TypeSystemClang , return {}; LLDB_LOG(log, - "[ClangASTImporter] DeportType called on ({0}Type*){1} " - "from (ASTContext*){2} to (ASTContext*){3}", + "[ClangASTImporter] DeportType called on ({0}Type*){1:x} " + "from (ASTContext*){2:x} to (ASTContext*){3:x}", src_type.GetTypeName(), src_type.GetOpaqueQualType(), _ctxt->getASTContext(), ()); @@ -334,8 +334,8 @@ clang::Decl *ClangASTImporter::DeportDecl(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx = >getASTContext(); LLDB_LOG(log, - "[ClangASTImporter] DeportDecl called on ({0}Decl*){1} from " - "(ASTContext*){2} to (ASTContext*){3}", + "[ClangASTImporter] DeportDecl called on ({0}Decl*){1:x} from " + "(ASTContext*){2:x} to (ASTContext*){3:x}", decl->getDeclKindName(), decl, src_ctx, dst_ctx); DeclContextOverride decl_context_override; @@ -352,8 +352,8 @@ clang::Decl *ClangASTImporter::DeportDecl(clang::ASTContext *dst_ctx, return nullptr; LLDB_LOG(log, - "[ClangASTImporter] DeportDecl deported ({0}Decl*){1} to " - "({2}Decl*){3}", + "[ClangASTImporter] DeportDecl deported ({0}Decl*){1:x} to " + "({2}Decl*){3:x}", decl->getDeclKindName(), decl, result->getDeclKindName(), result); return result; @@ -637,8 +637,8 @@ bool ClangASTImporter::importRecordLayoutFromOrigin( clang::ASTContext _ctx = record->getASTContext(); LLDB_LOG(log, - "LayoutRecordType on (ASTContext*){0} '{1}' for (RecordDecl*)" - "{2} [name = '{3}']", + "LayoutRecordType on (ASTContext*){0:x} '{1}' for (RecordDecl*)" + "{2:x} [name = '{3}']", _ctx, TypeSystemClang::GetASTContext(_ctx)->getDisplayName(), record, record->getName()); @@ -703,7 +703,7 @@ bool ClangASTImporter::importRecordLayoutFromOrigin( if (log) { LLDB_LOG(log, "LRT returned:"); -LLDB_LOG(log, "LRT Original = (RecordDecl*){0}", +LLDB_LOG(log, "LRT Original = (RecordDecl*){0:x}", static_cast(origin_record.decl)); LLDB_LOG(log, "LRT Size = {0}", size); LLDB_LOG(log, "LRT Alignment = {0}", alignment); @@ -712,7 +712,7 @@ bool ClangASTImporter::importRecordLayoutFromOrigin( fe = record->field_end(); fi != fe; ++fi) { LLDB_LOG(log, - "LRT (FieldDecl*){0}, Name = '{1}', Type = '{2}', Offset = " + "LRT (FieldDecl*){0:x}, Name = '{1}', Type = '{2}', Offset = " "{3} bits", *fi, fi->getName(), fi->getType().getAsString(), field_offsets[*fi]); @@ -734,7 +734,7 @@ bool ClangASTImporter::importRecordLayoutFromOrigin( DynCast(base_record); LLDB_LOG(log, - "LRT {0}(CXXRecordDecl*){1}, Name = '{2}', Offset = " + "LRT {0}(CXXRecordDecl*){1:x}, Name = '{2}', Offset = " "{3} chars", (is_virtual ? "Virtual " : ""), base_cxx_record.decl, base_cxx_record.decl->getName(), @@ -1025,7 +1025,7 @@ void ClangASTImporter::ForgetDestination(clang::ASTContext *dst_ast) { Log *log = GetLog(LLDBLog::Expressions); LLDB_LOG(log, - "[ClangASTImporter] Forgetting destination (ASTContext*){0}", + "[ClangASTImporter] Forgetting destination (ASTContext*){0:x}", dst_ast); m_metadata_map.erase(dst_ast); @@ -1039,7 +1039,7 @@ void ClangASTImporter::ForgetSource(clang::ASTContext *dst_ast, LLDB_LOG(log, "[ClangASTImporter] Forgetting source->dest " - "(ASTContext*){0}->(ASTContext*){1}", + "(ASTContext*){0:x}->(ASTContext*){1:x}", src_ast, dst_ast); if (!md) @@ -1164,9
[Lldb-commits] [lldb] [lldb][TypeSystem][NFCI] Log creation of new TypeSystem instances to expression log (PR #91985)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/91985 >From 1ccf935f97b21e0bd87955f3313cb47261d11379 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 13 May 2024 15:34:24 +0100 Subject: [PATCH 1/3] [lldb][TypeSystem][NFCI] Log creation of new TypeSystem instances to expression log We emit `ASTContext` and `TypeSystem` pointers into the `expr` log but there is no easy way (that I know of) to correlate the pointer value back to an easily readible form. This patch simply logs the name of the `TypeSystem` and the associated `ASTContext` into the `expr` channel whenever we create a new `TypeSystemClang`. --- .../TypeSystem/Clang/TypeSystemClang.cpp | 21 +++ .../TypeSystem/Clang/TypeSystemClang.h| 4 +++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index d0033fcd9cdfc..a7b5c55098de2 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -501,6 +501,8 @@ TypeSystemClang::TypeSystemClang(llvm::StringRef name, // The caller didn't pass an ASTContext so create a new one for this // TypeSystemClang. CreateASTContext(); + + LogCreation(); } TypeSystemClang::TypeSystemClang(llvm::StringRef name, @@ -510,6 +512,8 @@ TypeSystemClang::TypeSystemClang(llvm::StringRef name, m_ast_up.reset(_ctxt); GetASTMap().Insert(_ctxt, this); + + LogCreation(); } // Destructor @@ -544,13 +548,16 @@ lldb::TypeSystemSP TypeSystemClang::CreateInstance(lldb::LanguageType language, } } + lldb::TypeSystemSP instance; + if (module) { std::string ast_name = "ASTContext for '" + module->GetFileSpec().GetPath() + "'"; -return std::make_shared(ast_name, triple); +instance = std::make_shared(ast_name, triple); } else if (target && target->IsValid()) -return std::make_shared(*target, triple); - return lldb::TypeSystemSP(); +instance = std::make_shared(*target, triple); + + return instance; } LanguageSet TypeSystemClang::GetSupportedLanguagesForTypes() { @@ -630,7 +637,7 @@ void TypeSystemClang::SetExternalSource( ast.setExternalSource(ast_source_up); } -ASTContext ::getASTContext() { +ASTContext ::getASTContext() const { assert(m_ast_up); return *m_ast_up; } @@ -9750,3 +9757,9 @@ bool TypeSystemClang::SetDeclIsForcefullyCompleted(const clang::TagDecl *td) { metadata->SetIsForcefullyCompleted(); return true; } + +void TypeSystemClang::LogCreation() const { + if (auto *log = GetLog(LLDBLog::Expressions)) +LLDB_LOG(log, "Created new TypeSystem for (ASTContext*){0:x} '{1}'", + (), getDisplayName()); +} diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h index 59ca69622d9e8..6ba2c44c36584 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -162,7 +162,7 @@ class TypeSystemClang : public TypeSystem { llvm::StringRef getDisplayName() const { return m_display_name; } /// Returns the clang::ASTContext instance managed by this TypeSystemClang. - clang::ASTContext (); + clang::ASTContext () const; clang::MangleContext *getMangleContext(); @@ -1166,6 +1166,8 @@ class TypeSystemClang : public TypeSystem { bool IsTypeImpl(lldb::opaque_compiler_type_t type, llvm::function_ref predicate) const; + void LogCreation() const; + // Classes that inherit from TypeSystemClang can see and modify these std::string m_target_triple; std::unique_ptr m_ast_up; >From 8cb97736d9ba9bd2f1a0bc10f96c3ad7b9f9f59f Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 13 May 2024 17:19:21 +0100 Subject: [PATCH 2/3] fixup! revert obsolete changes --- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index a7b5c55098de2..8b9ef98071e68 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -548,16 +548,14 @@ lldb::TypeSystemSP TypeSystemClang::CreateInstance(lldb::LanguageType language, } } - lldb::TypeSystemSP instance; - if (module) { std::string ast_name = "ASTContext for '" + module->GetFileSpec().GetPath() + "'"; -instance = std::make_shared(ast_name, triple); +return std::make_shared(ast_name, triple); } else if (target && target->IsValid()) -instance = std::make_shared(*target, triple); +return std::make_shared(*target, triple); - return instance; + return lldb::TypeSystemSP(); } LanguageSet TypeSystemClang::GetSupportedLanguagesForTypes() {
[Lldb-commits] [lldb] [lldb][TypeSystem][NFCI] Log creation of new TypeSystem instances to expression log (PR #91985)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/91985 >From 1ccf935f97b21e0bd87955f3313cb47261d11379 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 13 May 2024 15:34:24 +0100 Subject: [PATCH 1/2] [lldb][TypeSystem][NFCI] Log creation of new TypeSystem instances to expression log We emit `ASTContext` and `TypeSystem` pointers into the `expr` log but there is no easy way (that I know of) to correlate the pointer value back to an easily readible form. This patch simply logs the name of the `TypeSystem` and the associated `ASTContext` into the `expr` channel whenever we create a new `TypeSystemClang`. --- .../TypeSystem/Clang/TypeSystemClang.cpp | 21 +++ .../TypeSystem/Clang/TypeSystemClang.h| 4 +++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index d0033fcd9cdfc..a7b5c55098de2 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -501,6 +501,8 @@ TypeSystemClang::TypeSystemClang(llvm::StringRef name, // The caller didn't pass an ASTContext so create a new one for this // TypeSystemClang. CreateASTContext(); + + LogCreation(); } TypeSystemClang::TypeSystemClang(llvm::StringRef name, @@ -510,6 +512,8 @@ TypeSystemClang::TypeSystemClang(llvm::StringRef name, m_ast_up.reset(_ctxt); GetASTMap().Insert(_ctxt, this); + + LogCreation(); } // Destructor @@ -544,13 +548,16 @@ lldb::TypeSystemSP TypeSystemClang::CreateInstance(lldb::LanguageType language, } } + lldb::TypeSystemSP instance; + if (module) { std::string ast_name = "ASTContext for '" + module->GetFileSpec().GetPath() + "'"; -return std::make_shared(ast_name, triple); +instance = std::make_shared(ast_name, triple); } else if (target && target->IsValid()) -return std::make_shared(*target, triple); - return lldb::TypeSystemSP(); +instance = std::make_shared(*target, triple); + + return instance; } LanguageSet TypeSystemClang::GetSupportedLanguagesForTypes() { @@ -630,7 +637,7 @@ void TypeSystemClang::SetExternalSource( ast.setExternalSource(ast_source_up); } -ASTContext ::getASTContext() { +ASTContext ::getASTContext() const { assert(m_ast_up); return *m_ast_up; } @@ -9750,3 +9757,9 @@ bool TypeSystemClang::SetDeclIsForcefullyCompleted(const clang::TagDecl *td) { metadata->SetIsForcefullyCompleted(); return true; } + +void TypeSystemClang::LogCreation() const { + if (auto *log = GetLog(LLDBLog::Expressions)) +LLDB_LOG(log, "Created new TypeSystem for (ASTContext*){0:x} '{1}'", + (), getDisplayName()); +} diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h index 59ca69622d9e8..6ba2c44c36584 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -162,7 +162,7 @@ class TypeSystemClang : public TypeSystem { llvm::StringRef getDisplayName() const { return m_display_name; } /// Returns the clang::ASTContext instance managed by this TypeSystemClang. - clang::ASTContext (); + clang::ASTContext () const; clang::MangleContext *getMangleContext(); @@ -1166,6 +1166,8 @@ class TypeSystemClang : public TypeSystem { bool IsTypeImpl(lldb::opaque_compiler_type_t type, llvm::function_ref predicate) const; + void LogCreation() const; + // Classes that inherit from TypeSystemClang can see and modify these std::string m_target_triple; std::unique_ptr m_ast_up; >From 8cb97736d9ba9bd2f1a0bc10f96c3ad7b9f9f59f Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 13 May 2024 17:19:21 +0100 Subject: [PATCH 2/2] fixup! revert obsolete changes --- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index a7b5c55098de2..8b9ef98071e68 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -548,16 +548,14 @@ lldb::TypeSystemSP TypeSystemClang::CreateInstance(lldb::LanguageType language, } } - lldb::TypeSystemSP instance; - if (module) { std::string ast_name = "ASTContext for '" + module->GetFileSpec().GetPath() + "'"; -instance = std::make_shared(ast_name, triple); +return std::make_shared(ast_name, triple); } else if (target && target->IsValid()) -instance = std::make_shared(*target, triple); +return std::make_shared(*target, triple); - return instance; + return lldb::TypeSystemSP(); } LanguageSet TypeSystemClang::GetSupportedLanguagesForTypes() {
[Lldb-commits] [lldb] [lldb][ExpressionParser][NFCI] Log pointers as hex (PR #91989)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/91989 >From 1fba045db76f51a2dbd9a2a3cb9879858b5b653e Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 13 May 2024 14:50:07 +0100 Subject: [PATCH 1/2] [lldb][ExpressionParser][NFCI] Log pointers as hex This ensures that we log pointers as lower-case hex. E.g., instead of: ``` LayoutRecordType on (ASTContext*)0x00010E78D600 'scratch ASTContext' for (RecordDecl*)0x00010E797 ``` we now log: ``` ``` --- .../Clang/ClangASTImporter.cpp| 48 +-- .../ExpressionParser/Clang/ClangASTSource.cpp | 44 - 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp index 30b50df79da90..2889bef26c3bc 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp @@ -313,8 +313,8 @@ CompilerType ClangASTImporter::DeportType(TypeSystemClang , return {}; LLDB_LOG(log, - "[ClangASTImporter] DeportType called on ({0}Type*){1} " - "from (ASTContext*){2} to (ASTContext*){3}", + "[ClangASTImporter] DeportType called on ({0}Type*){1:x} " + "from (ASTContext*){2:x} to (ASTContext*){3:x}", src_type.GetTypeName(), src_type.GetOpaqueQualType(), _ctxt->getASTContext(), ()); @@ -334,8 +334,8 @@ clang::Decl *ClangASTImporter::DeportDecl(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx = >getASTContext(); LLDB_LOG(log, - "[ClangASTImporter] DeportDecl called on ({0}Decl*){1} from " - "(ASTContext*){2} to (ASTContext*){3}", + "[ClangASTImporter] DeportDecl called on ({0}Decl*){1:x} from " + "(ASTContext*){2:x} to (ASTContext*){3:x}", decl->getDeclKindName(), decl, src_ctx, dst_ctx); DeclContextOverride decl_context_override; @@ -352,8 +352,8 @@ clang::Decl *ClangASTImporter::DeportDecl(clang::ASTContext *dst_ctx, return nullptr; LLDB_LOG(log, - "[ClangASTImporter] DeportDecl deported ({0}Decl*){1} to " - "({2}Decl*){3}", + "[ClangASTImporter] DeportDecl deported ({0}Decl*){1:x} to " + "({2}Decl*){3:x}", decl->getDeclKindName(), decl, result->getDeclKindName(), result); return result; @@ -637,8 +637,8 @@ bool ClangASTImporter::importRecordLayoutFromOrigin( clang::ASTContext _ctx = record->getASTContext(); LLDB_LOG(log, - "LayoutRecordType on (ASTContext*){0} '{1}' for (RecordDecl*)" - "{2} [name = '{3}']", + "LayoutRecordType on (ASTContext*){0:x} '{1}' for (RecordDecl*)" + "{2:x} [name = '{3}']", _ctx, TypeSystemClang::GetASTContext(_ctx)->getDisplayName(), record, record->getName()); @@ -703,7 +703,7 @@ bool ClangASTImporter::importRecordLayoutFromOrigin( if (log) { LLDB_LOG(log, "LRT returned:"); -LLDB_LOG(log, "LRT Original = (RecordDecl*){0}", +LLDB_LOG(log, "LRT Original = (RecordDecl*){0:x}", static_cast(origin_record.decl)); LLDB_LOG(log, "LRT Size = {0}", size); LLDB_LOG(log, "LRT Alignment = {0}", alignment); @@ -712,7 +712,7 @@ bool ClangASTImporter::importRecordLayoutFromOrigin( fe = record->field_end(); fi != fe; ++fi) { LLDB_LOG(log, - "LRT (FieldDecl*){0}, Name = '{1}', Type = '{2}', Offset = " + "LRT (FieldDecl*){0:x}, Name = '{1}', Type = '{2}', Offset = " "{3} bits", *fi, fi->getName(), fi->getType().getAsString(), field_offsets[*fi]); @@ -734,7 +734,7 @@ bool ClangASTImporter::importRecordLayoutFromOrigin( DynCast(base_record); LLDB_LOG(log, - "LRT {0}(CXXRecordDecl*){1}, Name = '{2}', Offset = " + "LRT {0}(CXXRecordDecl*){1:x}, Name = '{2}', Offset = " "{3} chars", (is_virtual ? "Virtual " : ""), base_cxx_record.decl, base_cxx_record.decl->getName(), @@ -1025,7 +1025,7 @@ void ClangASTImporter::ForgetDestination(clang::ASTContext *dst_ast) { Log *log = GetLog(LLDBLog::Expressions); LLDB_LOG(log, - "[ClangASTImporter] Forgetting destination (ASTContext*){0}", + "[ClangASTImporter] Forgetting destination (ASTContext*){0:x}", dst_ast); m_metadata_map.erase(dst_ast); @@ -1039,7 +1039,7 @@ void ClangASTImporter::ForgetSource(clang::ASTContext *dst_ast, LLDB_LOG(log, "[ClangASTImporter] Forgetting source->dest " - "(ASTContext*){0}->(ASTContext*){1}", + "(ASTContext*){0:x}->(ASTContext*){1:x}", src_ast, dst_ast); if (!md) @@ -1164,9
[Lldb-commits] [lldb] [lldb][ExpressionParser][NFCI] Log pointers as hex (PR #91989)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/91989 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][ExpressionParser][NFCI] Log pointers as hex (PR #91989)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/91989 This ensures that we log pointers as lower-case hex. E.g., instead of: ``` LayoutRecordType on (ASTContext*)0x00010E78D600 'scratch ASTContext' for (RecordDecl*)0x00010E797 ``` we now log: ``` LayoutRecordType on (ASTContext*)0x00010e78d600 'scratch ASTContext' for (RecordDecl*)0x00010e797 ``` Which is consistent with how the AST dump gets emitted into the log, making it easier to correlate pointers we log from LLDB and pointers that are part of any AST dumps in the same `expr` log. >From 1fba045db76f51a2dbd9a2a3cb9879858b5b653e Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 13 May 2024 14:50:07 +0100 Subject: [PATCH] [lldb][ExpressionParser][NFCI] Log pointers as hex This ensures that we log pointers as lower-case hex. E.g., instead of: ``` LayoutRecordType on (ASTContext*)0x00010E78D600 'scratch ASTContext' for (RecordDecl*)0x00010E797 ``` we now log: ``` ``` --- .../Clang/ClangASTImporter.cpp| 48 +-- .../ExpressionParser/Clang/ClangASTSource.cpp | 44 - 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp index 30b50df79da90..2889bef26c3bc 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp @@ -313,8 +313,8 @@ CompilerType ClangASTImporter::DeportType(TypeSystemClang , return {}; LLDB_LOG(log, - "[ClangASTImporter] DeportType called on ({0}Type*){1} " - "from (ASTContext*){2} to (ASTContext*){3}", + "[ClangASTImporter] DeportType called on ({0}Type*){1:x} " + "from (ASTContext*){2:x} to (ASTContext*){3:x}", src_type.GetTypeName(), src_type.GetOpaqueQualType(), _ctxt->getASTContext(), ()); @@ -334,8 +334,8 @@ clang::Decl *ClangASTImporter::DeportDecl(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx = >getASTContext(); LLDB_LOG(log, - "[ClangASTImporter] DeportDecl called on ({0}Decl*){1} from " - "(ASTContext*){2} to (ASTContext*){3}", + "[ClangASTImporter] DeportDecl called on ({0}Decl*){1:x} from " + "(ASTContext*){2:x} to (ASTContext*){3:x}", decl->getDeclKindName(), decl, src_ctx, dst_ctx); DeclContextOverride decl_context_override; @@ -352,8 +352,8 @@ clang::Decl *ClangASTImporter::DeportDecl(clang::ASTContext *dst_ctx, return nullptr; LLDB_LOG(log, - "[ClangASTImporter] DeportDecl deported ({0}Decl*){1} to " - "({2}Decl*){3}", + "[ClangASTImporter] DeportDecl deported ({0}Decl*){1:x} to " + "({2}Decl*){3:x}", decl->getDeclKindName(), decl, result->getDeclKindName(), result); return result; @@ -637,8 +637,8 @@ bool ClangASTImporter::importRecordLayoutFromOrigin( clang::ASTContext _ctx = record->getASTContext(); LLDB_LOG(log, - "LayoutRecordType on (ASTContext*){0} '{1}' for (RecordDecl*)" - "{2} [name = '{3}']", + "LayoutRecordType on (ASTContext*){0:x} '{1}' for (RecordDecl*)" + "{2:x} [name = '{3}']", _ctx, TypeSystemClang::GetASTContext(_ctx)->getDisplayName(), record, record->getName()); @@ -703,7 +703,7 @@ bool ClangASTImporter::importRecordLayoutFromOrigin( if (log) { LLDB_LOG(log, "LRT returned:"); -LLDB_LOG(log, "LRT Original = (RecordDecl*){0}", +LLDB_LOG(log, "LRT Original = (RecordDecl*){0:x}", static_cast(origin_record.decl)); LLDB_LOG(log, "LRT Size = {0}", size); LLDB_LOG(log, "LRT Alignment = {0}", alignment); @@ -712,7 +712,7 @@ bool ClangASTImporter::importRecordLayoutFromOrigin( fe = record->field_end(); fi != fe; ++fi) { LLDB_LOG(log, - "LRT (FieldDecl*){0}, Name = '{1}', Type = '{2}', Offset = " + "LRT (FieldDecl*){0:x}, Name = '{1}', Type = '{2}', Offset = " "{3} bits", *fi, fi->getName(), fi->getType().getAsString(), field_offsets[*fi]); @@ -734,7 +734,7 @@ bool ClangASTImporter::importRecordLayoutFromOrigin( DynCast(base_record); LLDB_LOG(log, - "LRT {0}(CXXRecordDecl*){1}, Name = '{2}', Offset = " + "LRT {0}(CXXRecordDecl*){1:x}, Name = '{2}', Offset = " "{3} chars", (is_virtual ? "Virtual " : ""), base_cxx_record.decl, base_cxx_record.decl->getName(), @@ -1025,7 +1025,7 @@ void ClangASTImporter::ForgetDestination(clang::ASTContext *dst_ast) { Log *log = GetLog(LLDBLog::Expressions); LLDB_LOG(log, - "[ClangASTImporter]
[Lldb-commits] [lldb] [lldb][TypeSystem][NFCI] Log creation of new TypeSystem instances to expression log (PR #91985)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/91985 We emit `ASTContext` and `TypeSystem` pointers into the `expr` log but there is no easy way (that I know of) to correlate the pointer value back to an easily readible form. This patch simply logs the name of the `TypeSystem` and the associated `ASTContext` into the `expr` channel whenever we create a new `TypeSystemClang`. The following is an example of the new log entries: ``` $ grep Created /tmp/lldb.log Created new TypeSystem for (ASTContext*)0x000101a2e200 'ASTContext for '/Users/michaelbuch/a.out'' Created new TypeSystem for (ASTContext*)0x000102512a00 'scratch ASTContext' Created new TypeSystem for (ASTContext*)0x000102116a00 'ClangModulesDeclVendor ASTContext' Created new TypeSystem for (ASTContext*)0x0001022e8c00 'Expression ASTContext for ''' Created new TypeSystem for (ASTContext*)0x0001103e7200 'AppleObjCTypeEncodingParser ASTContext' Created new TypeSystem for (ASTContext*)0x0001103f7000 'AppleObjCDeclVendor AST' Created new TypeSystem for (ASTContext*)0x0001104bfe00 'Expression ASTContext for ''' Created new TypeSystem for (ASTContext*)0x000101f01000 'Expression ASTContext for ''' Created new TypeSystem for (ASTContext*)0x0001025d3c00 'Expression ASTContext for ''' Created new TypeSystem for (ASTContext*)0x000110422400 'Expression ASTContext for ''' Created new TypeSystem for (ASTContext*)0x00011602c200 'Expression ASTContext for ''' Created new TypeSystem for (ASTContext*)0x000110641600 'Expression ASTContext for ''' Created new TypeSystem for (ASTContext*)0x000110617400 'Expression ASTContext for ''' ``` >From 1ccf935f97b21e0bd87955f3313cb47261d11379 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 13 May 2024 15:34:24 +0100 Subject: [PATCH] [lldb][TypeSystem][NFCI] Log creation of new TypeSystem instances to expression log We emit `ASTContext` and `TypeSystem` pointers into the `expr` log but there is no easy way (that I know of) to correlate the pointer value back to an easily readible form. This patch simply logs the name of the `TypeSystem` and the associated `ASTContext` into the `expr` channel whenever we create a new `TypeSystemClang`. --- .../TypeSystem/Clang/TypeSystemClang.cpp | 21 +++ .../TypeSystem/Clang/TypeSystemClang.h| 4 +++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index d0033fcd9cdfc..a7b5c55098de2 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -501,6 +501,8 @@ TypeSystemClang::TypeSystemClang(llvm::StringRef name, // The caller didn't pass an ASTContext so create a new one for this // TypeSystemClang. CreateASTContext(); + + LogCreation(); } TypeSystemClang::TypeSystemClang(llvm::StringRef name, @@ -510,6 +512,8 @@ TypeSystemClang::TypeSystemClang(llvm::StringRef name, m_ast_up.reset(_ctxt); GetASTMap().Insert(_ctxt, this); + + LogCreation(); } // Destructor @@ -544,13 +548,16 @@ lldb::TypeSystemSP TypeSystemClang::CreateInstance(lldb::LanguageType language, } } + lldb::TypeSystemSP instance; + if (module) { std::string ast_name = "ASTContext for '" + module->GetFileSpec().GetPath() + "'"; -return std::make_shared(ast_name, triple); +instance = std::make_shared(ast_name, triple); } else if (target && target->IsValid()) -return std::make_shared(*target, triple); - return lldb::TypeSystemSP(); +instance = std::make_shared(*target, triple); + + return instance; } LanguageSet TypeSystemClang::GetSupportedLanguagesForTypes() { @@ -630,7 +637,7 @@ void TypeSystemClang::SetExternalSource( ast.setExternalSource(ast_source_up); } -ASTContext ::getASTContext() { +ASTContext ::getASTContext() const { assert(m_ast_up); return *m_ast_up; } @@ -9750,3 +9757,9 @@ bool TypeSystemClang::SetDeclIsForcefullyCompleted(const clang::TagDecl *td) { metadata->SetIsForcefullyCompleted(); return true; } + +void TypeSystemClang::LogCreation() const { + if (auto *log = GetLog(LLDBLog::Expressions)) +LLDB_LOG(log, "Created new TypeSystem for (ASTContext*){0:x} '{1}'", + (), getDisplayName()); +} diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h index 59ca69622d9e8..6ba2c44c36584 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -162,7 +162,7 @@ class TypeSystemClang : public TypeSystem { llvm::StringRef getDisplayName() const { return m_display_name; } /// Returns the clang::ASTContext instance managed by this TypeSystemClang. - clang::ASTContext (); + clang::ASTContext () const;
[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)
Michael137 wrote: > I am somewhat worried about this slowing down the actual operations it is > reporting progress on. I didn't really measure this, but intuitively, I'd > expect that a one of these operations (parsing/importing one type) would be > pretty fast, and that the whole process takes so long simply because > performing a very large number of these ops. > > Can you get some numbers on this? E.g., the number of events (per second?) > that this generates, the timings of expression evaluation with/without the > patch, or something like that? I've been living on this patch for the past two weeks, debugging Clang/LLDB and haven't noticed a slowdown in the expression evaluator, but I'll try to follow-up with some concrete numbers. > Is the code that emits the progress event recursive too? The reason I ask is > because on the command line, nested progress events will get shadowed. The > same is true for coalesced progress events. I'm not sure how VSCode/DAP > clients deal with this, so maybe they're shown there? > Anyway, if the code is recursive, we might need to do something like we did > for Swift, with one top-level event and callback that updates the details. Yes it is recursive, and some of the progress events do shadow each other. I'll take a look at what Swift does, thanks for the pointer! https://github.com/llvm/llvm-project/pull/91452 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Improve type name parsing (PR #91586)
https://github.com/Michael137 approved this pull request. Looks much cleaner now, thanks! https://github.com/llvm/llvm-project/pull/91586 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Improve type name parsing (PR #91586)
@@ -492,12 +494,37 @@ class Type : public std::enable_shared_from_this, public UserID { static int Compare(const Type , const Type ); + // Represents a parsed type name coming out of GetTypeScopeAndBasename. The + // structure holds StringRefs pointing to portions of the original name, and + // so most not be used after the name is destroyed. Michael137 wrote: ```suggestion // so must not be used after the name is destroyed. ``` https://github.com/llvm/llvm-project/pull/91586 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Improve type name parsing (PR #91586)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/91586 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/91452 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)
@@ -1411,3 +1414,35 @@ clang::Decl * ClangASTImporter::ASTImporterDelegate::GetOriginalDecl(clang::Decl *To) { return m_main.GetDeclOrigin(To).decl; } + +void ClangASTImporter::ASTImporterDelegate::UpdateImportProgress( +clang::Decl const *From) { + assert(From && + "Trying to report import progress using an invalid clang::Decl."); + + // If we can't determine the decl's name, we don't know what to + // update the progress bar with. So bail out. + auto const *ND = dyn_cast(From); + if (!ND) +return; + + if (!m_import_progress_up) { +auto const *from_ast = +TypeSystemClang::GetASTContext(>getASTContext()); +auto const *to_ast = TypeSystemClang::GetASTContext(()); + +assert(from_ast && to_ast); + +llvm::SmallVector from_name_parts; +llvm::SplitString(from_ast->getDisplayName(), from_name_parts, "/"); +auto from_name = from_name_parts.back(); + +llvm::SmallVector to_name_parts; +llvm::SplitString(to_ast->getDisplayName(), to_name_parts, "/"); Michael137 wrote: > What does an ast's DisplayName look like? It's one of three: * `Expression ASTContext for '" + m_filename + "'` (expression AST) * `scratch ASTContext` * a module name https://github.com/llvm/llvm-project/pull/91452 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/91452 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)
@@ -1411,3 +1414,35 @@ clang::Decl * ClangASTImporter::ASTImporterDelegate::GetOriginalDecl(clang::Decl *To) { return m_main.GetDeclOrigin(To).decl; } + +void ClangASTImporter::ASTImporterDelegate::UpdateImportProgress( Michael137 wrote: These asserts should never ever actually occur unless something about TypeSystemClang gets redesigned, at which point the intention was that these would flag in development builds/tests. But definitely valid question. For the cases where a `nullptr` would occur I did try to be consistent with early returns. I usually try to express the preconditions of the function in terms of asserts, but in this case I don't have strong opinion, I think doing an early return would make sense here. I remember some time last year @DavidSpickett proposed an assert macro that would fire in debug builds but early-return in release. Can't find that atm, not sure if it ever landed. https://github.com/llvm/llvm-project/pull/91452 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)
Michael137 wrote: Example of what the DIE parsing progress looks like: https://github.com/llvm/llvm-project/assets/14071464/bd589ddd-c933-4e14-a380-f4db177e33d4 https://github.com/llvm/llvm-project/pull/91452 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/91452 This is an attempt at displaying the work that's being done by LLDB when waiting on type-completion events, e.g., when running an expression. We add three new progress reports (across three commits): 1. When moving decls between ASTs. 2. When creating Clang ASTs from DWARF. 3. When doing a FindTypes lookup on a debug map. Some remaining questions: 1. When do we want to destroy these `Progress` objects? Since the progress completed event is only sent on object destruction 2. How expensive is it to do this reporting unconditionally? 3. Are there more interesting places to report progress on? >From 18303da3e0b318860df9f13d6309cbf94d795f5b Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 8 May 2024 10:47:07 +0100 Subject: [PATCH 1/3] [lldb][ClangASTImporter] Report progress when importing decls --- .../Clang/ClangASTImporter.cpp| 35 +++ .../ExpressionParser/Clang/ClangASTImporter.h | 4 +++ 2 files changed, 39 insertions(+) diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp index 30b50df79da90..cf9f1a2d47922 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp @@ -7,6 +7,7 @@ //===--===// #include "lldb/Core/Module.h" +#include "lldb/Core/Progress.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" @@ -17,6 +18,7 @@ #include "clang/AST/RecordLayout.h" #include "clang/Sema/Lookup.h" #include "clang/Sema/Sema.h" +#include "llvm/ADT/ScopeExit.h" #include "llvm/Support/raw_ostream.h" #include "Plugins/ExpressionParser/Clang/ClangASTImporter.h" @@ -1131,6 +1133,7 @@ ClangASTImporter::ASTImporterDelegate::ImportImpl(Decl *From) { LLDB_LOG(log, "[ClangASTImporter] Complete definition not found"); } + UpdateImportProgress(From); return ASTImporter::ImportImpl(From); } @@ -1411,3 +1414,35 @@ clang::Decl * ClangASTImporter::ASTImporterDelegate::GetOriginalDecl(clang::Decl *To) { return m_main.GetDeclOrigin(To).decl; } + +void ClangASTImporter::ASTImporterDelegate::UpdateImportProgress( +clang::Decl const *From) { + assert(From && + "Trying to report import progress using an invalid clang::Decl."); + + // If we can't determine the decl's name, we don't know what to + // update the progress bar with. So bail out. + auto const *ND = dyn_cast(From); + if (!ND) +return; + + if (!m_import_progress_up) { +auto const *from_ast = +TypeSystemClang::GetASTContext(>getASTContext()); +auto const *to_ast = TypeSystemClang::GetASTContext(()); + +assert(from_ast && to_ast); + +llvm::SmallVector from_name_parts; +llvm::SplitString(from_ast->getDisplayName(), from_name_parts, "/"); +auto from_name = from_name_parts.back(); + +llvm::SmallVector to_name_parts; +llvm::SplitString(to_ast->getDisplayName(), to_name_parts, "/"); +auto to_name = to_name_parts.back(); +m_import_progress_up = std::make_unique( +llvm::formatv("Importing '{0}' to '{1}'", from_name, to_name)); + } + + m_import_progress_up->Increment(1, ND->getNameAsString()); +} diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h index bc962e544d2f1..f666d0c0fc52c 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h @@ -22,6 +22,7 @@ #include "clang/Basic/FileManager.h" #include "clang/Basic/FileSystemOptions.h" +#include "lldb/Core/Progress.h" #include "lldb/Host/FileSystem.h" #include "lldb/Symbol/CompilerDeclContext.h" #include "lldb/Utility/LLDBAssert.h" @@ -346,6 +347,8 @@ class ClangASTImporter { llvm::Expected ImportImpl(clang::Decl *From) override; private: +void UpdateImportProgress(clang::Decl const *From); + /// Decls we should ignore when mapping decls back to their original /// ASTContext. Used by the CxxModuleHandler to mark declarations that /// were created from the 'std' C++ module to prevent that the Importer @@ -356,6 +359,7 @@ class ClangASTImporter { CxxModuleHandler *m_std_handler = nullptr; /// The currently attached listener. NewDeclListener *m_new_decl_listener = nullptr; +std::unique_ptr m_import_progress_up = nullptr; }; typedef std::shared_ptr ImporterDelegateSP; >From 99d505d6ec7de91f48df06da1109f1206d410c38 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 8 May 2024 10:47:54 +0100 Subject: [PATCH 2/3] [lldb][DWARFASTParserClang] Report progress when parsing types from DWARF --- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 19 +++
[Lldb-commits] [lldb] [lldb] Make SBType::GetDirectNestedType (mostly) work with typedefs (PR #91189)
https://github.com/Michael137 approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/91189 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFCI] Remove unused DWARF value-to-name functions (PR #91010)
https://github.com/Michael137 approved this pull request. https://github.com/llvm/llvm-project/pull/91010 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBType::GetByteAlign (PR #90960)
https://github.com/Michael137 approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/90960 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)
Michael137 wrote: > > Is any of it testable? > > Good question. Though this is mostly meant to be "NFC" (with very large > quotes), I can imagine us doing something like forcing the parsing of a > specific type (`type lookup ` ?), and then checking that the > module ast (`image dump ast`) does _not_ contain specific types -- as that's > basically what we're trying to achieve. Yea that could work. But if it's going to be very painful or fragile to test then don't let that hold back the PR https://github.com/llvm/llvm-project/pull/90663 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/90663 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)
@@ -16,60 +16,65 @@ using namespace lldb_private::plugin::dwarf; bool UniqueDWARFASTTypeList::Find(const DWARFDIE , const lldb_private::Declaration , const int32_t byte_size, + bool is_forward_declaration, UniqueDWARFASTType ) const { for (const UniqueDWARFASTType : m_collection) { // Make sure the tags match if (udt.m_die.Tag() == die.Tag()) { - // Validate byte sizes of both types only if both are valid. - if (udt.m_byte_size < 0 || byte_size < 0 || - udt.m_byte_size == byte_size) { -// Make sure the file and line match -if (udt.m_declaration == decl) { - // The type has the same name, and was defined on the same file and - // line. Now verify all of the parent DIEs match. - DWARFDIE parent_arg_die = die.GetParent(); - DWARFDIE parent_pos_die = udt.m_die.GetParent(); - bool match = true; - bool done = false; - 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) { - switch (parent_arg_tag) { - case DW_TAG_class_type: - case DW_TAG_structure_type: - case DW_TAG_union_type: - case DW_TAG_namespace: { -const char *parent_arg_die_name = parent_arg_die.GetName(); -if (parent_arg_die_name == -nullptr) // Anonymous (i.e. no-name) struct -{ + // 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. + bool matching_size_declaration = + udt.m_is_forward_declaration != is_forward_declaration + ? true + : (udt.m_byte_size < 0 || byte_size < 0 || + udt.m_byte_size == byte_size) && +udt.m_declaration == decl; + if (matching_size_declaration) { Michael137 wrote: For readability, can we do: ``` if (!match_size_declaration) continue; ``` ? https://github.com/llvm/llvm-project/pull/90663 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)
https://github.com/Michael137 commented: The idea makes sense and I like that we could factor things out of `ParseStructureLikeDIE`, so generally LGTM (module Pavel's comments). Is any of it testable? https://github.com/llvm/llvm-project/pull/90663 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/90663 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)
@@ -1664,13 +1793,40 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext , } if (dwarf->GetUniqueDWARFASTTypeMap().Find( -unique_typename, die, unique_decl, attrs.byte_size.value_or(-1), -*unique_ast_entry_up)) { +unique_typename, die, unique_decl, byte_size, +attrs.is_forward_declaration, *unique_ast_entry_up)) { type_sp = unique_ast_entry_up->m_type_sp; if (type_sp) { dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get(); LinkDeclContextToDIE( GetCachedClangDeclContextForDIE(unique_ast_entry_up->m_die), die); +if (!attrs.is_forward_declaration) { + // If the parameter DIE is definition and the entry in the map is Michael137 wrote: I find `parameter DIE` a bit confusing. Made me think of templates or functions. Could we just reference the parameter, e.g., `If the 'die' being parsed is a definition ...` or something like that https://github.com/llvm/llvm-project/pull/90663 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Teach LocateExecutableSymbolFile to look into LOCALBASE on FreeBSD (PR #81355)
https://github.com/Michael137 approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/81355 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFCI] Unify DW_TAG -> string conversions (PR #90657)
https://github.com/Michael137 approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/90657 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/89981 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)
https://github.com/Michael137 approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/89981 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)
@@ -1203,26 +1203,23 @@ bool StackFrame::IsArtificial() const { return m_stack_frame_kind == StackFrame::Kind::Artificial; } -lldb::LanguageType StackFrame::GetLanguage() { +SourceLanguage StackFrame::GetLanguage() { CompileUnit *cu = GetSymbolContext(eSymbolContextCompUnit).comp_unit; if (cu) return cu->GetLanguage(); - return lldb::eLanguageTypeUnknown; + return {}; } -lldb::LanguageType StackFrame::GuessLanguage() { - LanguageType lang_type = GetLanguage(); +SourceLanguage StackFrame::GuessLanguage() { + SourceLanguage lang_type = GetLanguage(); if (lang_type == eLanguageTypeUnknown) { -SymbolContext sc = GetSymbolContext(eSymbolContextFunction -| eSymbolContextSymbol); -if (sc.function) { - lang_type = sc.function->GetMangled().GuessLanguage(); -} +SymbolContext sc = +GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol); +if (sc.function) + lang_type = LanguageType(sc.function->GetMangled().GuessLanguage()); Michael137 wrote: This works because the `SourceLanguage(LanguageType)` constructor isn't marked explicit. Would it be clearer to mark it explicit and instead rewrite this as `SourceLanguage(sc.function->GetMangled().GuessLanguage())` https://github.com/llvm/llvm-project/pull/89981 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SB API to access static constexpr member values (PR #89730)
@@ -1156,6 +1159,10 @@ CompilerType TypeSystemClang::GetTypeForDecl(ObjCInterfaceDecl *decl) { return GetType(getASTContext().getObjCInterfaceType(decl)); } +CompilerType TypeSystemClang::GetTypeForDecl(clang::ValueDecl *value_decl) { Michael137 wrote: Ahh makes sense, didn't look at the inheritance hierarchy carefully enough https://github.com/llvm/llvm-project/pull/89730 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SB API to access static constexpr member values (PR #89730)
@@ -107,6 +107,35 @@ class SBTypeMemberFunction { lldb::TypeMemberFunctionImplSP m_opaque_sp; }; +class LLDB_API SBTypeStaticField { +public: + SBTypeStaticField(); + + SBTypeStaticField(const lldb::SBTypeStaticField ); + lldb::SBTypeStaticField =(const lldb::SBTypeStaticField ); + + ~SBTypeStaticField(); + + explicit operator bool() const; + + bool IsValid() const; + + const char *GetName(); + + const char *GetMangledName(); + + lldb::SBType GetType(); + + lldb::SBValue GetConstantValue(lldb::SBTarget target); + +protected: + friend class SBType; + + SBTypeStaticField(lldb_private::CompilerDecl decl); Michael137 wrote: did you mean for this to not be marked `explicit`? https://github.com/llvm/llvm-project/pull/89730 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SB API to access static constexpr member values (PR #89730)
@@ -27,6 +27,7 @@ class Task { enum E : unsigned char {} e; union U { } u; +static constexpr long static_constexpr_field = 47; Michael137 wrote: Should we have an XFAIL test for the non-constant case? https://github.com/llvm/llvm-project/pull/89730 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SB API to access static constexpr member values (PR #89730)
@@ -9074,6 +9111,21 @@ CompilerType TypeSystemClang::DeclGetFunctionArgumentType(void *opaque_decl, return CompilerType(); } +Scalar TypeSystemClang::DeclGetConstantValue(void *opaque_decl) { + clang::Decl *decl = static_cast(opaque_decl); + if (clang::VarDecl *var_decl = llvm::dyn_cast(decl)) { Michael137 wrote: Minor: could follow the early-return style here https://github.com/llvm/llvm-project/pull/89730 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SB API to access static constexpr member values (PR #89730)
@@ -1156,6 +1159,10 @@ CompilerType TypeSystemClang::GetTypeForDecl(ObjCInterfaceDecl *decl) { return GetType(getASTContext().getObjCInterfaceType(decl)); } +CompilerType TypeSystemClang::GetTypeForDecl(clang::ValueDecl *value_decl) { Michael137 wrote: Could you remind me where the need for `ValueDecl` comes from? https://github.com/llvm/llvm-project/pull/89730 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SB API to access static constexpr member values (PR #89730)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/89730 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SB API to access static constexpr member values (PR #89730)
https://github.com/Michael137 approved this pull request. LGTM with some minor clarification questions/style comments https://github.com/llvm/llvm-project/pull/89730 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARF] Remove m_forward_decl_die_to_compiler_type as it never actually being used. (PR #89427)
https://github.com/Michael137 approved this pull request. https://github.com/llvm/llvm-project/pull/89427 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARF] Remove m_forward_decl_die_to_compiler_type as it never actually being used. (PR #89427)
Michael137 wrote: LGTM thanks for the cleanup! https://github.com/llvm/llvm-project/pull/89427 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make SBType::FindDirectNestedType work with expression ASTs (PR #89183)
https://github.com/Michael137 approved this pull request. https://github.com/llvm/llvm-project/pull/89183 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make SBType::FindDirectNestedType work with expression ASTs (PR #89183)
Michael137 wrote: > > One thing I'd like to get feedback on is whether this should be looking > > into base classes. The discussion on the original PR focuses on lexically > > nested types, but going through base classes (following usual language > > rules) is another form of nesting. Both the existing and the new > > implementations don't do that, but I think it would be more natural to do > > it. Of course, then the function can definitely return more than one > > result... > > What you're describing here is in line with member lookup described in the > Standard. While it might be a useful facility, it's at odds with the intent > of `FindDirectNestedTypes()` to be a small building block for efficient AST > traversal. For the use case I have for this function, any amount of lookup is > going to regress the performance of the formatter, and subsequently > responsiveness of the debugger. So if you're going to pursue this, I suggest > exposing this as a new function. I don't expect the simple `DeclContext` lookup proposed here to be expensive. What *is* expensive from the data-formatters point of view is either full-blown expression evaluation or a global search in DWARF for some type. Re. looking at base classes, don't have a strong opinion on it. There's some precedent for looking at base classes already in `TypeSystemClang` (e.g., `GetIndexOfChildWithName`). But as you say @labath, that would require an API change https://github.com/llvm/llvm-project/pull/89183 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][ClangExpressionDeclMap][NFC] Remove unused NameSearchContext::m_found_function (PR #88724)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/88724 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][ClangExpressionDeclMap][NFC] Remove unused NameSearchContext::m_found_function (PR #88724)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/88724 >From e85bf75077dec2d6aa7d6983bbde222d1c2b3f29 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 15 Apr 2024 10:37:05 +0100 Subject: [PATCH 1/2] [lldb][ClangExpressionDeclMap][NFC] Remove unused NameSearchContext::m_found_function This member was never actually used, ever since its introduction in `ca4e0fd7e63b90e6f68044af47248c64f250ee8f`. --- .../ExpressionParser/Clang/ClangExpressionDeclMap.cpp| 9 ++--- .../Plugins/ExpressionParser/Clang/NameSearchContext.h | 1 - 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index 2d306b42760b18..bf310cfcd4c8af 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -1049,7 +1049,6 @@ void ClangExpressionDeclMap::LookupInModulesDeclVendor( context.AddNamedDecl(copied_function); context.m_found_function_with_type_info = true; -context.m_found_function = true; } else if (auto copied_var = dyn_cast(copied_decl)) { context.AddNamedDecl(copied_var); context.m_found_variable = true; @@ -1299,7 +1298,6 @@ void ClangExpressionDeclMap::LookupFunction( AddOneFunction(context, sym_ctx.function, nullptr); context.m_found_function_with_type_info = true; -context.m_found_function = true; } else if (sym_ctx.symbol) { Symbol *symbol = sym_ctx.symbol; if (target && symbol->GetType() == eSymbolTypeReExported) { @@ -1329,13 +1327,10 @@ void ClangExpressionDeclMap::LookupFunction( } if (!context.m_found_function_with_type_info) { - if (extern_symbol) { + if (extern_symbol) AddOneFunction(context, nullptr, extern_symbol); -context.m_found_function = true; - } else if (non_extern_symbol) { + else if (non_extern_symbol) AddOneFunction(context, nullptr, non_extern_symbol); -context.m_found_function = true; - } } } } diff --git a/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.h b/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.h index dc8621dd6aba52..9a3320636081be 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.h @@ -41,7 +41,6 @@ struct NameSearchContext { bool m_found_variable = false; bool m_found_function_with_type_info = false; - bool m_found_function = false; bool m_found_local_vars_nsp = false; bool m_found_type = false; >From 86314daa00da7be807a14f81ae98816dc7172b29 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 15 Apr 2024 13:40:55 +0100 Subject: [PATCH 2/2] fixup! revert noisy formatting change --- .../ExpressionParser/Clang/ClangExpressionDeclMap.cpp| 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index bf310cfcd4c8af..31f6447d66f642 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -1327,10 +1327,11 @@ void ClangExpressionDeclMap::LookupFunction( } if (!context.m_found_function_with_type_info) { - if (extern_symbol) + if (extern_symbol) { AddOneFunction(context, nullptr, extern_symbol); - else if (non_extern_symbol) + } else if (non_extern_symbol) { AddOneFunction(context, nullptr, non_extern_symbol); + } } } } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][TypeSystemClang][NFCI] Use LangOptions::setLangDefaults when creating new LangOptions (PR #88721)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/88721 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][TypeSystemClang][NFCI] Use LangOptions::setLangDefaults when creating new LangOptions (PR #88721)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/88721 >From f0b309c52a7f497aa021f38f3ce272a1bb3e66ea Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 15 Apr 2024 13:16:58 +0100 Subject: [PATCH] [lldb][TypeSystemClang][NFCI] Use LangOptions::setLangDefaults when creating new LangOptions This logic was originally copied from `CompilerInstance::parseLangArgs`. Since then, the `CompilerInstance` uses `LangOptions::setLangDefaults` to set up new `LangOptions` instances. In our case, we only ever passed `Language::ObjCXX` into LLDB's `ParseLangArgs`, so most of this function was dead code. This patch replaces the duplicated logic with a call to `LangOptions::setLangDefaults`. --- .../TypeSystem/Clang/TypeSystemClang.cpp | 79 ++- 1 file changed, 6 insertions(+), 73 deletions(-) diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 44bd02bd4b367d..be0ddb06f82c18 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -459,85 +459,19 @@ TypeSystemClang::ConvertAccessTypeToAccessSpecifier(AccessType access) { return AS_none; } -static void ParseLangArgs(LangOptions , InputKind IK, const char *triple) { +static void ParseLangArgs(LangOptions , ArchSpec arch) { // FIXME: Cleanup per-file based stuff. - // Set some properties which depend solely on the input kind; it would be - // nice to move these to the language standard, and have the driver resolve - // the input kind + language standard. - if (IK.getLanguage() == clang::Language::Asm) { -Opts.AsmPreprocessor = 1; - } else if (IK.isObjectiveC()) { -Opts.ObjC = 1; - } - - LangStandard::Kind LangStd = LangStandard::lang_unspecified; - - if (LangStd == LangStandard::lang_unspecified) { -// Based on the base language, pick one. -switch (IK.getLanguage()) { -case clang::Language::Unknown: -case clang::Language::CIR: -case clang::Language::LLVM_IR: -case clang::Language::RenderScript: - llvm_unreachable("Invalid input kind!"); -case clang::Language::OpenCL: - LangStd = LangStandard::lang_opencl10; - break; -case clang::Language::OpenCLCXX: - LangStd = LangStandard::lang_openclcpp10; - break; -case clang::Language::Asm: -case clang::Language::C: -case clang::Language::ObjC: - LangStd = LangStandard::lang_gnu99; - break; -case clang::Language::CXX: -case clang::Language::ObjCXX: - LangStd = LangStandard::lang_gnucxx98; - break; -case clang::Language::CUDA: -case clang::Language::HIP: - LangStd = LangStandard::lang_gnucxx17; - break; -case clang::Language::HLSL: - LangStd = LangStandard::lang_hlsl; - break; -} - } - - const LangStandard = LangStandard::getLangStandardForKind(LangStd); - Opts.LineComment = Std.hasLineComments(); - Opts.C99 = Std.isC99(); - Opts.CPlusPlus = Std.isCPlusPlus(); - Opts.CPlusPlus11 = Std.isCPlusPlus11(); - Opts.CPlusPlus14 = Std.isCPlusPlus14(); - Opts.CPlusPlus17 = Std.isCPlusPlus17(); - Opts.CPlusPlus20 = Std.isCPlusPlus20(); - Opts.Digraphs = Std.hasDigraphs(); - Opts.GNUMode = Std.isGNUMode(); - Opts.GNUInline = !Std.isC99(); - Opts.HexFloats = Std.hasHexFloats(); - - Opts.WChar = true; - - // OpenCL has some additional defaults. - if (LangStd == LangStandard::lang_opencl10) { -Opts.OpenCL = 1; -Opts.AltiVec = 1; -Opts.CXXOperatorNames = 1; -Opts.setLaxVectorConversions(LangOptions::LaxVectorConversionKind::All); - } - - // OpenCL and C++ both have bool, true, false keywords. - Opts.Bool = Opts.OpenCL || Opts.CPlusPlus; + std::vector Includes; + LangOptions::setLangDefaults(Opts, clang::Language::ObjCXX, arch.GetTriple(), + Includes, clang::LangStandard::lang_gnucxx98); Opts.setValueVisibilityMode(DefaultVisibility); // Mimicing gcc's behavior, trigraphs are only enabled if -trigraphs is // specified, or -std is set to a conforming mode. Opts.Trigraphs = !Opts.GNUMode; - Opts.CharIsSigned = ArchSpec(triple).CharIsSignedByDefault(); + Opts.CharIsSigned = arch.CharIsSignedByDefault(); Opts.OptimizeSize = 0; // FIXME: Eliminate this dependency. @@ -727,8 +661,7 @@ void TypeSystemClang::CreateASTContext() { m_ast_owned = true; m_language_options_up = std::make_unique(); - ParseLangArgs(*m_language_options_up, clang::Language::ObjCXX, -GetTargetTriple()); + ParseLangArgs(*m_language_options_up, ArchSpec(GetTargetTriple())); m_identifier_table_up = std::make_unique(*m_language_options_up, nullptr); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFC] Turn ChildCacheState into an unscoped enum (PR #88703)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/88703 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][ClangExpressionDeclMap][NFC] Remove unused NameSearchContext::m_found_function (PR #88724)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/88724 This member was never actually used, ever since its introduction in `ca4e0fd7e63b90e6f68044af47248c64f250ee8f`. >From e85bf75077dec2d6aa7d6983bbde222d1c2b3f29 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 15 Apr 2024 10:37:05 +0100 Subject: [PATCH 1/2] [lldb][ClangExpressionDeclMap][NFC] Remove unused NameSearchContext::m_found_function This member was never actually used, ever since its introduction in `ca4e0fd7e63b90e6f68044af47248c64f250ee8f`. --- .../ExpressionParser/Clang/ClangExpressionDeclMap.cpp| 9 ++--- .../Plugins/ExpressionParser/Clang/NameSearchContext.h | 1 - 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index 2d306b42760b18..bf310cfcd4c8af 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -1049,7 +1049,6 @@ void ClangExpressionDeclMap::LookupInModulesDeclVendor( context.AddNamedDecl(copied_function); context.m_found_function_with_type_info = true; -context.m_found_function = true; } else if (auto copied_var = dyn_cast(copied_decl)) { context.AddNamedDecl(copied_var); context.m_found_variable = true; @@ -1299,7 +1298,6 @@ void ClangExpressionDeclMap::LookupFunction( AddOneFunction(context, sym_ctx.function, nullptr); context.m_found_function_with_type_info = true; -context.m_found_function = true; } else if (sym_ctx.symbol) { Symbol *symbol = sym_ctx.symbol; if (target && symbol->GetType() == eSymbolTypeReExported) { @@ -1329,13 +1327,10 @@ void ClangExpressionDeclMap::LookupFunction( } if (!context.m_found_function_with_type_info) { - if (extern_symbol) { + if (extern_symbol) AddOneFunction(context, nullptr, extern_symbol); -context.m_found_function = true; - } else if (non_extern_symbol) { + else if (non_extern_symbol) AddOneFunction(context, nullptr, non_extern_symbol); -context.m_found_function = true; - } } } } diff --git a/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.h b/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.h index dc8621dd6aba52..9a3320636081be 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.h @@ -41,7 +41,6 @@ struct NameSearchContext { bool m_found_variable = false; bool m_found_function_with_type_info = false; - bool m_found_function = false; bool m_found_local_vars_nsp = false; bool m_found_type = false; >From 86314daa00da7be807a14f81ae98816dc7172b29 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 15 Apr 2024 13:40:55 +0100 Subject: [PATCH 2/2] fixup! revert noisy formatting change --- .../ExpressionParser/Clang/ClangExpressionDeclMap.cpp| 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index bf310cfcd4c8af..31f6447d66f642 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -1327,10 +1327,11 @@ void ClangExpressionDeclMap::LookupFunction( } if (!context.m_found_function_with_type_info) { - if (extern_symbol) + if (extern_symbol) { AddOneFunction(context, nullptr, extern_symbol); - else if (non_extern_symbol) + } else if (non_extern_symbol) { AddOneFunction(context, nullptr, non_extern_symbol); + } } } } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][TypeSystemClang][NFCI] Use LangOptions::setLangDefaults when creating new LangOptions (PR #88721)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/88721 This logic was originally copied from `CompilerInstance::parseLangArgs`. Since then, the `CompilerInstance` uses `LangOptions::setLangDefaults` to set up new `LangOptions` instances. In our case, we only ever passed `Language::ObjCXX` into LLDB's `ParseLangArgs`, so most of this function was dead code. This patch replaces the duplicated logic with a call to `LangOptions::setLangDefaults`. >From f0b309c52a7f497aa021f38f3ce272a1bb3e66ea Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 15 Apr 2024 13:16:58 +0100 Subject: [PATCH] [lldb][TypeSystemClang][NFCI] Use LangOptions::setLangDefaults when creating new LangOptions This logic was originally copied from `CompilerInstance::parseLangArgs`. Since then, the `CompilerInstance` uses `LangOptions::setLangDefaults` to set up new `LangOptions` instances. In our case, we only ever passed `Language::ObjCXX` into LLDB's `ParseLangArgs`, so most of this function was dead code. This patch replaces the duplicated logic with a call to `LangOptions::setLangDefaults`. --- .../TypeSystem/Clang/TypeSystemClang.cpp | 79 ++- 1 file changed, 6 insertions(+), 73 deletions(-) diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 44bd02bd4b367d..be0ddb06f82c18 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -459,85 +459,19 @@ TypeSystemClang::ConvertAccessTypeToAccessSpecifier(AccessType access) { return AS_none; } -static void ParseLangArgs(LangOptions , InputKind IK, const char *triple) { +static void ParseLangArgs(LangOptions , ArchSpec arch) { // FIXME: Cleanup per-file based stuff. - // Set some properties which depend solely on the input kind; it would be - // nice to move these to the language standard, and have the driver resolve - // the input kind + language standard. - if (IK.getLanguage() == clang::Language::Asm) { -Opts.AsmPreprocessor = 1; - } else if (IK.isObjectiveC()) { -Opts.ObjC = 1; - } - - LangStandard::Kind LangStd = LangStandard::lang_unspecified; - - if (LangStd == LangStandard::lang_unspecified) { -// Based on the base language, pick one. -switch (IK.getLanguage()) { -case clang::Language::Unknown: -case clang::Language::CIR: -case clang::Language::LLVM_IR: -case clang::Language::RenderScript: - llvm_unreachable("Invalid input kind!"); -case clang::Language::OpenCL: - LangStd = LangStandard::lang_opencl10; - break; -case clang::Language::OpenCLCXX: - LangStd = LangStandard::lang_openclcpp10; - break; -case clang::Language::Asm: -case clang::Language::C: -case clang::Language::ObjC: - LangStd = LangStandard::lang_gnu99; - break; -case clang::Language::CXX: -case clang::Language::ObjCXX: - LangStd = LangStandard::lang_gnucxx98; - break; -case clang::Language::CUDA: -case clang::Language::HIP: - LangStd = LangStandard::lang_gnucxx17; - break; -case clang::Language::HLSL: - LangStd = LangStandard::lang_hlsl; - break; -} - } - - const LangStandard = LangStandard::getLangStandardForKind(LangStd); - Opts.LineComment = Std.hasLineComments(); - Opts.C99 = Std.isC99(); - Opts.CPlusPlus = Std.isCPlusPlus(); - Opts.CPlusPlus11 = Std.isCPlusPlus11(); - Opts.CPlusPlus14 = Std.isCPlusPlus14(); - Opts.CPlusPlus17 = Std.isCPlusPlus17(); - Opts.CPlusPlus20 = Std.isCPlusPlus20(); - Opts.Digraphs = Std.hasDigraphs(); - Opts.GNUMode = Std.isGNUMode(); - Opts.GNUInline = !Std.isC99(); - Opts.HexFloats = Std.hasHexFloats(); - - Opts.WChar = true; - - // OpenCL has some additional defaults. - if (LangStd == LangStandard::lang_opencl10) { -Opts.OpenCL = 1; -Opts.AltiVec = 1; -Opts.CXXOperatorNames = 1; -Opts.setLaxVectorConversions(LangOptions::LaxVectorConversionKind::All); - } - - // OpenCL and C++ both have bool, true, false keywords. - Opts.Bool = Opts.OpenCL || Opts.CPlusPlus; + std::vector Includes; + LangOptions::setLangDefaults(Opts, clang::Language::ObjCXX, arch.GetTriple(), + Includes, clang::LangStandard::lang_gnucxx98); Opts.setValueVisibilityMode(DefaultVisibility); // Mimicing gcc's behavior, trigraphs are only enabled if -trigraphs is // specified, or -std is set to a conforming mode. Opts.Trigraphs = !Opts.GNUMode; - Opts.CharIsSigned = ArchSpec(triple).CharIsSignedByDefault(); + Opts.CharIsSigned = arch.CharIsSignedByDefault(); Opts.OptimizeSize = 0; // FIXME: Eliminate this dependency. @@ -727,8 +661,7 @@ void TypeSystemClang::CreateASTContext() { m_ast_owned = true; m_language_options_up = std::make_unique(); - ParseLangArgs(*m_language_options_up, clang::Language::ObjCXX, -
[Lldb-commits] [lldb] [lldb][NFC] Turn ChildCacheState into an unscoped enum (PR #88703)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/88703 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Turn ChildCacheState into an unscoped enum (PR #88703)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/88703 Done for consistency with the rest of the enums in `lldb-enumerations.h`. See https://github.com/llvm/llvm-project/pull/80167#issuecomment-2043721298 >From ba9d7105b334e3969e7f9f172cae37ea4f2f553e Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 15 Apr 2024 10:10:17 +0100 Subject: [PATCH] [lldb] Turn ChildCacheState into an unscoped enum Done for consistency with the rest of the enums in `lldb-enumerations.h`. See https://github.com/llvm/llvm-project/pull/80167#issuecomment-2043721298 --- lldb/include/lldb/lldb-enumerations.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index f3b07ea6d20395..15e45857186091 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -1310,7 +1310,7 @@ enum CompletionType { /// Specifies if children need to be re-computed /// after a call to \ref SyntheticChildrenFrontEnd::Update. -enum class ChildCacheState { +enum ChildCacheState { eRefetch = 0, ///< Children need to be recomputed dynamically. eReuse = 1, ///< Children did not change and don't need to be recomputed; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][libc++] Adds valarray proxy data formatters. (PR #88613)
https://github.com/Michael137 approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/88613 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][libc++] Adds valarray proxy data formatters. (PR #88613)
@@ -0,0 +1,194 @@ +//===-- LibCxxProxyArray.cpp---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "LibCxx.h" + +#include "lldb/Core/ValueObject.h" +#include "lldb/DataFormatters/FormattersHelpers.h" +#include + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::formatters; + +namespace lldb_private { +namespace formatters { + +/// Data formatter for libc++'s std::"proxy_array". +/// +/// A proxy_array's are created by using: +/// std::gslice_array operator[](const std::gslice& gslicearr); +/// std::mask_array operator[](const std::valarray& boolarr); +/// std::indirect_array operator[](const std::valarray& indarr); +/// +/// These arrays have the following members: +/// - __vp_ points to std::valarray::__begin_ +/// - __1d_ an array of offsets of the elements from @a __vp_ +class LibcxxStdProxyArraySyntheticFrontEnd : public SyntheticChildrenFrontEnd { +public: + LibcxxStdProxyArraySyntheticFrontEnd(lldb::ValueObjectSP valobj_sp); + + ~LibcxxStdProxyArraySyntheticFrontEnd() override; + + llvm::Expected CalculateNumChildren() override; + + lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; + + lldb::ChildCacheState Update() override; + + bool MightHaveChildren() override; + + size_t GetIndexOfChildWithName(ConstString name) override; + +private: + /// A non-owning pointer to the array's __vp_. + ValueObject *m_base = nullptr; + /// The type of the array's template argument T. + CompilerType m_element_type; + /// The sizeof the array's template argument T. + uint32_t m_element_size = 0; + + /// A non-owning pointer to the array's __1d_.__begin_. + ValueObject *m_start = nullptr; + /// A non-owning pointer to the array's __1d_.__end_. + ValueObject *m_finish = nullptr; + /// The type of the __1d_ array's template argument T (size_t). + CompilerType m_element_type_size_t; + /// The sizeof the __1d_ array's template argument T (size_t) + uint32_t m_element_size_size_t = 0; +}; + +} // namespace formatters +} // namespace lldb_private + +lldb_private::formatters::LibcxxStdProxyArraySyntheticFrontEnd:: +LibcxxStdProxyArraySyntheticFrontEnd(lldb::ValueObjectSP valobj_sp) +: SyntheticChildrenFrontEnd(*valobj_sp), m_element_type() { + if (valobj_sp) +Update(); +} + +lldb_private::formatters::LibcxxStdProxyArraySyntheticFrontEnd:: +~LibcxxStdProxyArraySyntheticFrontEnd() { + // these need to stay around because they are child objects who will follow + // their parent's life cycle + // delete m_base; +} + +llvm::Expected lldb_private::formatters:: +LibcxxStdProxyArraySyntheticFrontEnd::CalculateNumChildren() { Michael137 wrote: This is outside the scope of this PR but eventually we might want to pull this out into a helper or something since we have this implementation across multiple formatters now. Same with `GetChildAtIndex`. https://github.com/llvm/llvm-project/pull/88613 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [lldb] [libc++][CI] Tests LLDB libc++ data formatters. (PR #88312)
Michael137 wrote: Awesome, thanks for doing this!! https://github.com/llvm/llvm-project/pull/88312 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add tests for evaluating local variables whose name clashes with Objective-C types (PR #87807)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/87807 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add tests for evaluating local variables whose name clashes with Objective-C types (PR #87807)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/87807 >From 734e127b758b00210aa508c84d0222165c036ac4 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Fri, 5 Apr 2024 12:10:09 +0100 Subject: [PATCH 1/2] [lldb][test] Add tests for evaluating local variables whose name clashes with Objective-C types Depends on https://github.com/llvm/llvm-project/pull/87767 --- .../objc-builtin-types/TestObjCBuiltinTypes.py | 13 + .../API/lang/objcxx/objc-builtin-types/main.cpp | 8 +++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py index 611c7388999058..19ae2f091bdd5e 100644 --- a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py +++ b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py @@ -13,6 +13,7 @@ def setUp(self): # Find the line numbers to break inside main(). self.main_source = "main.cpp" self.break_line = line_number(self.main_source, "// Set breakpoint here.") +self.bar_break_line = line_number(self.main_source, "return id + Class") @add_test_categories(["pyapi"]) def test_with_python_api(self): @@ -26,6 +27,11 @@ def test_with_python_api(self): bpt = target.BreakpointCreateByLocation(self.main_source, self.break_line) self.assertTrue(bpt, VALID_BREAKPOINT) +bar_bpt = target.BreakpointCreateByLocation( +self.main_source, self.bar_break_line +) +self.assertTrue(bar_bpt, VALID_BREAKPOINT) + # Now launch the process, and do not stop at entry point. process = target.LaunchSimple(None, None, self.get_process_working_directory()) @@ -52,3 +58,10 @@ def test_with_python_api(self): patterns=["\(id\) \$.* = nil"], ) self.expect("expr --language C++ -- id my_id = 0; my_id", error=True) + +lldbutil.continue_to_breakpoint(process, bar_bpt) + +self.expect_expr("id", result_value="12", result_type="int") +self.expect_expr("Class", result_value="15", result_type="int") +self.expect("expr --language C++ -- id", error=True) +self.expect("expr --language C++ -- Class", error=True) diff --git a/lldb/test/API/lang/objcxx/objc-builtin-types/main.cpp b/lldb/test/API/lang/objcxx/objc-builtin-types/main.cpp index 6dd8cbc6e9fef6..5b35ec0f0b8c98 100644 --- a/lldb/test/API/lang/objcxx/objc-builtin-types/main.cpp +++ b/lldb/test/API/lang/objcxx/objc-builtin-types/main.cpp @@ -2,8 +2,14 @@ namespace ns { typedef int id; }; +int bar() { + int id = 12; + int Class = 15; + return id + Class; +} + int main() { ns::id foo = 0; - return foo; // Set breakpoint here. + return foo + bar(); // Set breakpoint here. } >From 081c72dd4d61279a999fb70e8aefd289a327de3f Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Fri, 12 Apr 2024 16:03:41 +0200 Subject: [PATCH 2/2] fixup! fix test --- .../lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py| 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py index 19ae2f091bdd5e..3cdca31b8969bd 100644 --- a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py +++ b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py @@ -63,5 +63,5 @@ def test_with_python_api(self): self.expect_expr("id", result_value="12", result_type="int") self.expect_expr("Class", result_value="15", result_type="int") -self.expect("expr --language C++ -- id", error=True) -self.expect("expr --language C++ -- Class", error=True) +self.expect("expr --language Objective-C++ -- id", error=True) +self.expect("expr --language Objective-C++ -- Class", error=True) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][libc++] Adds local_t clock data formatters. (PR #88178)
https://github.com/Michael137 approved this pull request. LGTM, thanks! https://github.com/llvm/llvm-project/pull/88178 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][libc++] Adds local_t clock data formatters. (PR #88178)
@@ -1068,6 +1068,29 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { eTypeOptionCascade, true); + AddCXXSummary( + cpp_category_sp, + lldb_private::formatters::LibcxxChronoLocalSecondsSummaryProvider, + "libc++ std::chrono::local_seconds summary provider", + "^std::__[[:alnum:]]+::chrono::time_point<" + "std::__[[:alnum:]]+::chrono::local_t, " + "std::__[[:alnum:]]+::chrono::durationhttps://github.com/llvm/llvm-project/pull/88178 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add tests for evaluating local variables whose name clashes with Objective-C types (PR #87807)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/87807 >From 734e127b758b00210aa508c84d0222165c036ac4 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Fri, 5 Apr 2024 12:10:09 +0100 Subject: [PATCH] [lldb][test] Add tests for evaluating local variables whose name clashes with Objective-C types Depends on https://github.com/llvm/llvm-project/pull/87767 --- .../objc-builtin-types/TestObjCBuiltinTypes.py | 13 + .../API/lang/objcxx/objc-builtin-types/main.cpp | 8 +++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py index 611c7388999058..19ae2f091bdd5e 100644 --- a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py +++ b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py @@ -13,6 +13,7 @@ def setUp(self): # Find the line numbers to break inside main(). self.main_source = "main.cpp" self.break_line = line_number(self.main_source, "// Set breakpoint here.") +self.bar_break_line = line_number(self.main_source, "return id + Class") @add_test_categories(["pyapi"]) def test_with_python_api(self): @@ -26,6 +27,11 @@ def test_with_python_api(self): bpt = target.BreakpointCreateByLocation(self.main_source, self.break_line) self.assertTrue(bpt, VALID_BREAKPOINT) +bar_bpt = target.BreakpointCreateByLocation( +self.main_source, self.bar_break_line +) +self.assertTrue(bar_bpt, VALID_BREAKPOINT) + # Now launch the process, and do not stop at entry point. process = target.LaunchSimple(None, None, self.get_process_working_directory()) @@ -52,3 +58,10 @@ def test_with_python_api(self): patterns=["\(id\) \$.* = nil"], ) self.expect("expr --language C++ -- id my_id = 0; my_id", error=True) + +lldbutil.continue_to_breakpoint(process, bar_bpt) + +self.expect_expr("id", result_value="12", result_type="int") +self.expect_expr("Class", result_value="15", result_type="int") +self.expect("expr --language C++ -- id", error=True) +self.expect("expr --language C++ -- Class", error=True) diff --git a/lldb/test/API/lang/objcxx/objc-builtin-types/main.cpp b/lldb/test/API/lang/objcxx/objc-builtin-types/main.cpp index 6dd8cbc6e9fef6..5b35ec0f0b8c98 100644 --- a/lldb/test/API/lang/objcxx/objc-builtin-types/main.cpp +++ b/lldb/test/API/lang/objcxx/objc-builtin-types/main.cpp @@ -2,8 +2,14 @@ namespace ns { typedef int id; }; +int bar() { + int id = 12; + int Class = 15; + return id + Class; +} + int main() { ns::id foo = 0; - return foo; // Set breakpoint here. + return foo + bar(); // Set breakpoint here. } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits