diff --git a/lldb/source/Plugins/Language/Swift/FoundationValueTypes.cpp b/lldb/source/Plugins/Language/Swift/FoundationValueTypes.cpp index 47d36840fe39b..ebebc157575f8 100644 --- a/lldb/source/Plugins/Language/Swift/FoundationValueTypes.cpp +++ b/lldb/source/Plugins/Language/Swift/FoundationValueTypes.cpp @@ -22,6 +22,9 @@ #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/StreamString.h" #include "lldb/Utility/Status.h" #include "lldb/ValueObject/ValueObject.h" #include "lldb/lldb-enumerations.h" @@ -419,6 +422,53 @@ bool lldb_private::formatters::swift::Data_SummaryProvider( if (!success) { return false; } + + // rdar://182785830 diagnostic. An inline Data can hold at most 14 bytes, so + // any larger `length` proves the reflection-derived layout of InlineData + // resolved the `length` field to the wrong offset/size. The canonical bad + // value is 197121 == 0x00030201 == the buffer bytes [1,2,3,0] read as a + // 4-byte int at offset 0. Dump the geometry so the failing CI run explains + // itself (part02 runs `log enable lldb types`, so this is captured). + if (count < 0 || count > 14) { + auto byte_size = [](const ValueObjectSP &v) -> uint64_t { + return llvm::expectedToStdOptional(v->GetByteSize()).value_or(0); + }; + StreamString ss; + ss.Printf("[rdar182785830] IMPOSSIBLE inline length=%lld (cap 14). " + "length{type=%s, byte_size=%llu} " + "InlineData{byte_size=%llu, num_children=%u} children=[", + (long long)count, + length_sp->GetTypeName().AsCString(""), + (unsigned long long)byte_size(length_sp), + (unsigned long long)byte_size(inline_data_sp), + inline_data_sp->GetNumChildrenIgnoringErrors()); + for (uint32_t i = 0, e = inline_data_sp->GetNumChildrenIgnoringErrors(); + i < e; ++i) { + ValueObjectSP c = inline_data_sp->GetChildAtIndex(i, true); + if (!c) + continue; + ss.Printf("%s%s:off=%llu:size=%llu", i ? ", " : "", + c->GetName().AsCString(""), + (unsigned long long)c->GetByteOffset(), + (unsigned long long)byte_size(c)); + } + ss.PutCString("] raw="); + DataExtractor bytes; + Status extract_err; + if (inline_data_sp->GetData(bytes, extract_err)) { + lldb::offset_t off = 0; + for (uint64_t i = 0; i < bytes.GetByteSize(); ++i) + ss.Printf("%02x ", bytes.GetU8(&off)); + } + // Emit into BOTH the log and the summary itself. The summary is what + // dotest prints in the `expect` failure ("Got output: ..."), so this is + // guaranteed to reach the console when the test fails, without depending + // on a log channel being captured. + LLDB_LOG(GetLog(LLDBLog::DataFormatters | LLDBLog::Types), "{0}", + ss.GetString()); + stream.PutCString(ss.GetString()); + stream.PutCString(" "); + } } else if (representation_case == g_slice) { // Grab the associated value from `case slice(InlineSlice)`. if (representation_enum_sp->GetNumChildrenIgnoringErrors() != 1) diff --git a/lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp b/lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp index 6d8111c017c71..293fb89c0ce2d 100644 --- a/lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp +++ b/lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp @@ -1971,6 +1971,7 @@ llvm::Expected SwiftLanguageRuntime::GetChildCompilerTypeAtIndex( uint64_t &language_flags) { CompilerType child_type; bool found = false; + ConstString parent_mangled = type.GetMangledTypeName(); SwiftRuntimeTypeVisitor visitor(*this, type, valobj, omit_empty_base_classes); llvm::Error error = visitor.VisitChildAtIndex( idx, @@ -1985,6 +1986,15 @@ llvm::Expected SwiftLanguageRuntime::GetChildCompilerTypeAtIndex( child_name = get_child_name(); child_byte_size = child.byte_size; child_byte_offset = child.byte_offset; + // rdar://182785830: trace the geometry each field resolves to, so a + // wrong result for a resilient field (e.g. Data.InlineData.length + // resolving to offset 0 / size 4 instead of offset 14 / size 1) is + // visible in the types log at the exact moment of resolution. + LLDB_LOG(GetLog(LLDBLog::Types), + "[GetChildCompilerTypeAtIndex] {0} field #{1} '{2}' -> " + "byte_offset={3} byte_size={4}", + parent_mangled.GetStringRef(), (unsigned)idx, + child_name, child_byte_offset, child_byte_size); child_bitfield_bit_size = child.bitfield_bit_size; child_bitfield_bit_offset = child.bitfield_bit_offset; child_is_base_class = child.is_base_class; diff --git a/lldb/test/API/lang/swift/array_tuple_resilient/main.swift b/lldb/test/API/lang/swift/array_tuple_resilient/main.swift index 93b277b8f0a26..c49faa25f528c 100644 --- a/lldb/test/API/lang/swift/array_tuple_resilient/main.swift +++ b/lldb/test/API/lang/swift/array_tuple_resilient/main.swift @@ -6,11 +6,11 @@ import Foundation var patatino : [(Data, Int64)] = [(Data([1, 2, 3]), 1001)] var tinky : [(Data, Data)] = [(Data([1, 2, 3]), Data([9]))] print(patatino) //%self.expect('frame variable -d run -- patatino', - //% substrs=['byte', '1 = 1001']) + //% substrs=['0 = 3 bytes', '1 = 1001']) //%self.expect('expr -d run -- patatino', - //% substrs=['byte', '1 = 1001']) + //% substrs=['0 = 3 bytes', '1 = 1001']) print(tinky) //%self.expect('frame variable -d run -- tinky', - //% substrs=['byte']) + //% substrs=['0 = 3 bytes', '1 = 1 byte']) //%self.expect('expr -d run -- tinky', - //% substrs=['byte']) + //% substrs=['0 = 3 bytes', '1 = 1 byte']) diff --git a/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer00.py b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer00.py new file mode 100644 index 0000000000000..7578d52104519 --- /dev/null +++ b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer00.py @@ -0,0 +1,33 @@ +# Auto-generated hammer shard for rdar://182785830 (flaky inline Data -> "197121 +# bytes" instead of "3 bytes"). Independent, single-iteration copy of the +# explicit_modules part02 test_import check, so lit runs many in parallel to +# amplify attempts AND concurrent/CPU-starved load without any single test +# exceeding the 600s per-test timeout. Delete before merging. +import os +import shutil +import lldb +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbtest as lldbtest +import lldbsuite.test.lldbutil as lldbutil + + +class TestSwiftDataHammer00(lldbtest.TestBase): + + @skipEmbeddedSwift + @swiftTest + @skipUnlessDarwin + def test_import(self): + """Repeat (via sharding) the flaky inline-Data resolution check.""" + mod_cache = self.getBuildArtifact("my-clang-modules-cache") + if os.path.isdir(mod_cache): + shutil.rmtree(mod_cache) + self.runCmd('settings set symbols.clang-modules-cache-path "%s"' + % mod_cache) + + self.build() + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( + self, 'Set breakpoint here', lldb.SBFileSpec('main.swift')) + + self.expect('expression Data([1, 2, 3])', error=True) + self.expect("expression import Foundation") + self.expect('expression Data([1, 2, 3])', substrs=["3 bytes"]) diff --git a/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer01.py b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer01.py new file mode 100644 index 0000000000000..d920fc8ed03bf --- /dev/null +++ b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer01.py @@ -0,0 +1,33 @@ +# Auto-generated hammer shard for rdar://182785830 (flaky inline Data -> "197121 +# bytes" instead of "3 bytes"). Independent, single-iteration copy of the +# explicit_modules part02 test_import check, so lit runs many in parallel to +# amplify attempts AND concurrent/CPU-starved load without any single test +# exceeding the 600s per-test timeout. Delete before merging. +import os +import shutil +import lldb +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbtest as lldbtest +import lldbsuite.test.lldbutil as lldbutil + + +class TestSwiftDataHammer01(lldbtest.TestBase): + + @skipEmbeddedSwift + @swiftTest + @skipUnlessDarwin + def test_import(self): + """Repeat (via sharding) the flaky inline-Data resolution check.""" + mod_cache = self.getBuildArtifact("my-clang-modules-cache") + if os.path.isdir(mod_cache): + shutil.rmtree(mod_cache) + self.runCmd('settings set symbols.clang-modules-cache-path "%s"' + % mod_cache) + + self.build() + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( + self, 'Set breakpoint here', lldb.SBFileSpec('main.swift')) + + self.expect('expression Data([1, 2, 3])', error=True) + self.expect("expression import Foundation") + self.expect('expression Data([1, 2, 3])', substrs=["3 bytes"]) diff --git a/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer02.py b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer02.py new file mode 100644 index 0000000000000..bdc5bfb0ff10e --- /dev/null +++ b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer02.py @@ -0,0 +1,33 @@ +# Auto-generated hammer shard for rdar://182785830 (flaky inline Data -> "197121 +# bytes" instead of "3 bytes"). Independent, single-iteration copy of the +# explicit_modules part02 test_import check, so lit runs many in parallel to +# amplify attempts AND concurrent/CPU-starved load without any single test +# exceeding the 600s per-test timeout. Delete before merging. +import os +import shutil +import lldb +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbtest as lldbtest +import lldbsuite.test.lldbutil as lldbutil + + +class TestSwiftDataHammer02(lldbtest.TestBase): + + @skipEmbeddedSwift + @swiftTest + @skipUnlessDarwin + def test_import(self): + """Repeat (via sharding) the flaky inline-Data resolution check.""" + mod_cache = self.getBuildArtifact("my-clang-modules-cache") + if os.path.isdir(mod_cache): + shutil.rmtree(mod_cache) + self.runCmd('settings set symbols.clang-modules-cache-path "%s"' + % mod_cache) + + self.build() + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( + self, 'Set breakpoint here', lldb.SBFileSpec('main.swift')) + + self.expect('expression Data([1, 2, 3])', error=True) + self.expect("expression import Foundation") + self.expect('expression Data([1, 2, 3])', substrs=["3 bytes"]) diff --git a/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer03.py b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer03.py new file mode 100644 index 0000000000000..6f00e3ec5fcbe --- /dev/null +++ b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer03.py @@ -0,0 +1,33 @@ +# Auto-generated hammer shard for rdar://182785830 (flaky inline Data -> "197121 +# bytes" instead of "3 bytes"). Independent, single-iteration copy of the +# explicit_modules part02 test_import check, so lit runs many in parallel to +# amplify attempts AND concurrent/CPU-starved load without any single test +# exceeding the 600s per-test timeout. Delete before merging. +import os +import shutil +import lldb +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbtest as lldbtest +import lldbsuite.test.lldbutil as lldbutil + + +class TestSwiftDataHammer03(lldbtest.TestBase): + + @skipEmbeddedSwift + @swiftTest + @skipUnlessDarwin + def test_import(self): + """Repeat (via sharding) the flaky inline-Data resolution check.""" + mod_cache = self.getBuildArtifact("my-clang-modules-cache") + if os.path.isdir(mod_cache): + shutil.rmtree(mod_cache) + self.runCmd('settings set symbols.clang-modules-cache-path "%s"' + % mod_cache) + + self.build() + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( + self, 'Set breakpoint here', lldb.SBFileSpec('main.swift')) + + self.expect('expression Data([1, 2, 3])', error=True) + self.expect("expression import Foundation") + self.expect('expression Data([1, 2, 3])', substrs=["3 bytes"]) diff --git a/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer04.py b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer04.py new file mode 100644 index 0000000000000..1c098a6df9e0b --- /dev/null +++ b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer04.py @@ -0,0 +1,33 @@ +# Auto-generated hammer shard for rdar://182785830 (flaky inline Data -> "197121 +# bytes" instead of "3 bytes"). Independent, single-iteration copy of the +# explicit_modules part02 test_import check, so lit runs many in parallel to +# amplify attempts AND concurrent/CPU-starved load without any single test +# exceeding the 600s per-test timeout. Delete before merging. +import os +import shutil +import lldb +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbtest as lldbtest +import lldbsuite.test.lldbutil as lldbutil + + +class TestSwiftDataHammer04(lldbtest.TestBase): + + @skipEmbeddedSwift + @swiftTest + @skipUnlessDarwin + def test_import(self): + """Repeat (via sharding) the flaky inline-Data resolution check.""" + mod_cache = self.getBuildArtifact("my-clang-modules-cache") + if os.path.isdir(mod_cache): + shutil.rmtree(mod_cache) + self.runCmd('settings set symbols.clang-modules-cache-path "%s"' + % mod_cache) + + self.build() + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( + self, 'Set breakpoint here', lldb.SBFileSpec('main.swift')) + + self.expect('expression Data([1, 2, 3])', error=True) + self.expect("expression import Foundation") + self.expect('expression Data([1, 2, 3])', substrs=["3 bytes"]) diff --git a/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer05.py b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer05.py new file mode 100644 index 0000000000000..195fde97fa5a4 --- /dev/null +++ b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer05.py @@ -0,0 +1,33 @@ +# Auto-generated hammer shard for rdar://182785830 (flaky inline Data -> "197121 +# bytes" instead of "3 bytes"). Independent, single-iteration copy of the +# explicit_modules part02 test_import check, so lit runs many in parallel to +# amplify attempts AND concurrent/CPU-starved load without any single test +# exceeding the 600s per-test timeout. Delete before merging. +import os +import shutil +import lldb +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbtest as lldbtest +import lldbsuite.test.lldbutil as lldbutil + + +class TestSwiftDataHammer05(lldbtest.TestBase): + + @skipEmbeddedSwift + @swiftTest + @skipUnlessDarwin + def test_import(self): + """Repeat (via sharding) the flaky inline-Data resolution check.""" + mod_cache = self.getBuildArtifact("my-clang-modules-cache") + if os.path.isdir(mod_cache): + shutil.rmtree(mod_cache) + self.runCmd('settings set symbols.clang-modules-cache-path "%s"' + % mod_cache) + + self.build() + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( + self, 'Set breakpoint here', lldb.SBFileSpec('main.swift')) + + self.expect('expression Data([1, 2, 3])', error=True) + self.expect("expression import Foundation") + self.expect('expression Data([1, 2, 3])', substrs=["3 bytes"]) diff --git a/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer06.py b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer06.py new file mode 100644 index 0000000000000..01cb7c47f65d1 --- /dev/null +++ b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer06.py @@ -0,0 +1,33 @@ +# Auto-generated hammer shard for rdar://182785830 (flaky inline Data -> "197121 +# bytes" instead of "3 bytes"). Independent, single-iteration copy of the +# explicit_modules part02 test_import check, so lit runs many in parallel to +# amplify attempts AND concurrent/CPU-starved load without any single test +# exceeding the 600s per-test timeout. Delete before merging. +import os +import shutil +import lldb +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbtest as lldbtest +import lldbsuite.test.lldbutil as lldbutil + + +class TestSwiftDataHammer06(lldbtest.TestBase): + + @skipEmbeddedSwift + @swiftTest + @skipUnlessDarwin + def test_import(self): + """Repeat (via sharding) the flaky inline-Data resolution check.""" + mod_cache = self.getBuildArtifact("my-clang-modules-cache") + if os.path.isdir(mod_cache): + shutil.rmtree(mod_cache) + self.runCmd('settings set symbols.clang-modules-cache-path "%s"' + % mod_cache) + + self.build() + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( + self, 'Set breakpoint here', lldb.SBFileSpec('main.swift')) + + self.expect('expression Data([1, 2, 3])', error=True) + self.expect("expression import Foundation") + self.expect('expression Data([1, 2, 3])', substrs=["3 bytes"]) diff --git a/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer07.py b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer07.py new file mode 100644 index 0000000000000..b278bd28490f1 --- /dev/null +++ b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer07.py @@ -0,0 +1,33 @@ +# Auto-generated hammer shard for rdar://182785830 (flaky inline Data -> "197121 +# bytes" instead of "3 bytes"). Independent, single-iteration copy of the +# explicit_modules part02 test_import check, so lit runs many in parallel to +# amplify attempts AND concurrent/CPU-starved load without any single test +# exceeding the 600s per-test timeout. Delete before merging. +import os +import shutil +import lldb +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbtest as lldbtest +import lldbsuite.test.lldbutil as lldbutil + + +class TestSwiftDataHammer07(lldbtest.TestBase): + + @skipEmbeddedSwift + @swiftTest + @skipUnlessDarwin + def test_import(self): + """Repeat (via sharding) the flaky inline-Data resolution check.""" + mod_cache = self.getBuildArtifact("my-clang-modules-cache") + if os.path.isdir(mod_cache): + shutil.rmtree(mod_cache) + self.runCmd('settings set symbols.clang-modules-cache-path "%s"' + % mod_cache) + + self.build() + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( + self, 'Set breakpoint here', lldb.SBFileSpec('main.swift')) + + self.expect('expression Data([1, 2, 3])', error=True) + self.expect("expression import Foundation") + self.expect('expression Data([1, 2, 3])', substrs=["3 bytes"]) diff --git a/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer08.py b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer08.py new file mode 100644 index 0000000000000..1ded10650c742 --- /dev/null +++ b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer08.py @@ -0,0 +1,33 @@ +# Auto-generated hammer shard for rdar://182785830 (flaky inline Data -> "197121 +# bytes" instead of "3 bytes"). Independent, single-iteration copy of the +# explicit_modules part02 test_import check, so lit runs many in parallel to +# amplify attempts AND concurrent/CPU-starved load without any single test +# exceeding the 600s per-test timeout. Delete before merging. +import os +import shutil +import lldb +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbtest as lldbtest +import lldbsuite.test.lldbutil as lldbutil + + +class TestSwiftDataHammer08(lldbtest.TestBase): + + @skipEmbeddedSwift + @swiftTest + @skipUnlessDarwin + def test_import(self): + """Repeat (via sharding) the flaky inline-Data resolution check.""" + mod_cache = self.getBuildArtifact("my-clang-modules-cache") + if os.path.isdir(mod_cache): + shutil.rmtree(mod_cache) + self.runCmd('settings set symbols.clang-modules-cache-path "%s"' + % mod_cache) + + self.build() + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( + self, 'Set breakpoint here', lldb.SBFileSpec('main.swift')) + + self.expect('expression Data([1, 2, 3])', error=True) + self.expect("expression import Foundation") + self.expect('expression Data([1, 2, 3])', substrs=["3 bytes"]) diff --git a/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer09.py b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer09.py new file mode 100644 index 0000000000000..d14332eca27ff --- /dev/null +++ b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer09.py @@ -0,0 +1,33 @@ +# Auto-generated hammer shard for rdar://182785830 (flaky inline Data -> "197121 +# bytes" instead of "3 bytes"). Independent, single-iteration copy of the +# explicit_modules part02 test_import check, so lit runs many in parallel to +# amplify attempts AND concurrent/CPU-starved load without any single test +# exceeding the 600s per-test timeout. Delete before merging. +import os +import shutil +import lldb +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbtest as lldbtest +import lldbsuite.test.lldbutil as lldbutil + + +class TestSwiftDataHammer09(lldbtest.TestBase): + + @skipEmbeddedSwift + @swiftTest + @skipUnlessDarwin + def test_import(self): + """Repeat (via sharding) the flaky inline-Data resolution check.""" + mod_cache = self.getBuildArtifact("my-clang-modules-cache") + if os.path.isdir(mod_cache): + shutil.rmtree(mod_cache) + self.runCmd('settings set symbols.clang-modules-cache-path "%s"' + % mod_cache) + + self.build() + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( + self, 'Set breakpoint here', lldb.SBFileSpec('main.swift')) + + self.expect('expression Data([1, 2, 3])', error=True) + self.expect("expression import Foundation") + self.expect('expression Data([1, 2, 3])', substrs=["3 bytes"]) diff --git a/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer10.py b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer10.py new file mode 100644 index 0000000000000..e25115d20f326 --- /dev/null +++ b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer10.py @@ -0,0 +1,33 @@ +# Auto-generated hammer shard for rdar://182785830 (flaky inline Data -> "197121 +# bytes" instead of "3 bytes"). Independent, single-iteration copy of the +# explicit_modules part02 test_import check, so lit runs many in parallel to +# amplify attempts AND concurrent/CPU-starved load without any single test +# exceeding the 600s per-test timeout. Delete before merging. +import os +import shutil +import lldb +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbtest as lldbtest +import lldbsuite.test.lldbutil as lldbutil + + +class TestSwiftDataHammer10(lldbtest.TestBase): + + @skipEmbeddedSwift + @swiftTest + @skipUnlessDarwin + def test_import(self): + """Repeat (via sharding) the flaky inline-Data resolution check.""" + mod_cache = self.getBuildArtifact("my-clang-modules-cache") + if os.path.isdir(mod_cache): + shutil.rmtree(mod_cache) + self.runCmd('settings set symbols.clang-modules-cache-path "%s"' + % mod_cache) + + self.build() + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( + self, 'Set breakpoint here', lldb.SBFileSpec('main.swift')) + + self.expect('expression Data([1, 2, 3])', error=True) + self.expect("expression import Foundation") + self.expect('expression Data([1, 2, 3])', substrs=["3 bytes"]) diff --git a/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer11.py b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer11.py new file mode 100644 index 0000000000000..2d0b7282a70ab --- /dev/null +++ b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer11.py @@ -0,0 +1,33 @@ +# Auto-generated hammer shard for rdar://182785830 (flaky inline Data -> "197121 +# bytes" instead of "3 bytes"). Independent, single-iteration copy of the +# explicit_modules part02 test_import check, so lit runs many in parallel to +# amplify attempts AND concurrent/CPU-starved load without any single test +# exceeding the 600s per-test timeout. Delete before merging. +import os +import shutil +import lldb +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbtest as lldbtest +import lldbsuite.test.lldbutil as lldbutil + + +class TestSwiftDataHammer11(lldbtest.TestBase): + + @skipEmbeddedSwift + @swiftTest + @skipUnlessDarwin + def test_import(self): + """Repeat (via sharding) the flaky inline-Data resolution check.""" + mod_cache = self.getBuildArtifact("my-clang-modules-cache") + if os.path.isdir(mod_cache): + shutil.rmtree(mod_cache) + self.runCmd('settings set symbols.clang-modules-cache-path "%s"' + % mod_cache) + + self.build() + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( + self, 'Set breakpoint here', lldb.SBFileSpec('main.swift')) + + self.expect('expression Data([1, 2, 3])', error=True) + self.expect("expression import Foundation") + self.expect('expression Data([1, 2, 3])', substrs=["3 bytes"]) diff --git a/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer12.py b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer12.py new file mode 100644 index 0000000000000..470d9e0dd690e --- /dev/null +++ b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer12.py @@ -0,0 +1,33 @@ +# Auto-generated hammer shard for rdar://182785830 (flaky inline Data -> "197121 +# bytes" instead of "3 bytes"). Independent, single-iteration copy of the +# explicit_modules part02 test_import check, so lit runs many in parallel to +# amplify attempts AND concurrent/CPU-starved load without any single test +# exceeding the 600s per-test timeout. Delete before merging. +import os +import shutil +import lldb +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbtest as lldbtest +import lldbsuite.test.lldbutil as lldbutil + + +class TestSwiftDataHammer12(lldbtest.TestBase): + + @skipEmbeddedSwift + @swiftTest + @skipUnlessDarwin + def test_import(self): + """Repeat (via sharding) the flaky inline-Data resolution check.""" + mod_cache = self.getBuildArtifact("my-clang-modules-cache") + if os.path.isdir(mod_cache): + shutil.rmtree(mod_cache) + self.runCmd('settings set symbols.clang-modules-cache-path "%s"' + % mod_cache) + + self.build() + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( + self, 'Set breakpoint here', lldb.SBFileSpec('main.swift')) + + self.expect('expression Data([1, 2, 3])', error=True) + self.expect("expression import Foundation") + self.expect('expression Data([1, 2, 3])', substrs=["3 bytes"]) diff --git a/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer13.py b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer13.py new file mode 100644 index 0000000000000..c8af0c56a50aa --- /dev/null +++ b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer13.py @@ -0,0 +1,33 @@ +# Auto-generated hammer shard for rdar://182785830 (flaky inline Data -> "197121 +# bytes" instead of "3 bytes"). Independent, single-iteration copy of the +# explicit_modules part02 test_import check, so lit runs many in parallel to +# amplify attempts AND concurrent/CPU-starved load without any single test +# exceeding the 600s per-test timeout. Delete before merging. +import os +import shutil +import lldb +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbtest as lldbtest +import lldbsuite.test.lldbutil as lldbutil + + +class TestSwiftDataHammer13(lldbtest.TestBase): + + @skipEmbeddedSwift + @swiftTest + @skipUnlessDarwin + def test_import(self): + """Repeat (via sharding) the flaky inline-Data resolution check.""" + mod_cache = self.getBuildArtifact("my-clang-modules-cache") + if os.path.isdir(mod_cache): + shutil.rmtree(mod_cache) + self.runCmd('settings set symbols.clang-modules-cache-path "%s"' + % mod_cache) + + self.build() + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( + self, 'Set breakpoint here', lldb.SBFileSpec('main.swift')) + + self.expect('expression Data([1, 2, 3])', error=True) + self.expect("expression import Foundation") + self.expect('expression Data([1, 2, 3])', substrs=["3 bytes"]) diff --git a/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer14.py b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer14.py new file mode 100644 index 0000000000000..972c59190e0c6 --- /dev/null +++ b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer14.py @@ -0,0 +1,33 @@ +# Auto-generated hammer shard for rdar://182785830 (flaky inline Data -> "197121 +# bytes" instead of "3 bytes"). Independent, single-iteration copy of the +# explicit_modules part02 test_import check, so lit runs many in parallel to +# amplify attempts AND concurrent/CPU-starved load without any single test +# exceeding the 600s per-test timeout. Delete before merging. +import os +import shutil +import lldb +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbtest as lldbtest +import lldbsuite.test.lldbutil as lldbutil + + +class TestSwiftDataHammer14(lldbtest.TestBase): + + @skipEmbeddedSwift + @swiftTest + @skipUnlessDarwin + def test_import(self): + """Repeat (via sharding) the flaky inline-Data resolution check.""" + mod_cache = self.getBuildArtifact("my-clang-modules-cache") + if os.path.isdir(mod_cache): + shutil.rmtree(mod_cache) + self.runCmd('settings set symbols.clang-modules-cache-path "%s"' + % mod_cache) + + self.build() + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( + self, 'Set breakpoint here', lldb.SBFileSpec('main.swift')) + + self.expect('expression Data([1, 2, 3])', error=True) + self.expect("expression import Foundation") + self.expect('expression Data([1, 2, 3])', substrs=["3 bytes"]) diff --git a/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer15.py b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer15.py new file mode 100644 index 0000000000000..872fc9ba498cb --- /dev/null +++ b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftDataHammer15.py @@ -0,0 +1,33 @@ +# Auto-generated hammer shard for rdar://182785830 (flaky inline Data -> "197121 +# bytes" instead of "3 bytes"). Independent, single-iteration copy of the +# explicit_modules part02 test_import check, so lit runs many in parallel to +# amplify attempts AND concurrent/CPU-starved load without any single test +# exceeding the 600s per-test timeout. Delete before merging. +import os +import shutil +import lldb +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbtest as lldbtest +import lldbsuite.test.lldbutil as lldbutil + + +class TestSwiftDataHammer15(lldbtest.TestBase): + + @skipEmbeddedSwift + @swiftTest + @skipUnlessDarwin + def test_import(self): + """Repeat (via sharding) the flaky inline-Data resolution check.""" + mod_cache = self.getBuildArtifact("my-clang-modules-cache") + if os.path.isdir(mod_cache): + shutil.rmtree(mod_cache) + self.runCmd('settings set symbols.clang-modules-cache-path "%s"' + % mod_cache) + + self.build() + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( + self, 'Set breakpoint here', lldb.SBFileSpec('main.swift')) + + self.expect('expression Data([1, 2, 3])', error=True) + self.expect("expression import Foundation") + self.expect('expression Data([1, 2, 3])', substrs=["3 bytes"]) diff --git a/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftExplicitModules_part02.py b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftExplicitModules_part02.py index f0d0063f0718e..abf778529ad9e 100644 --- a/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftExplicitModules_part02.py +++ b/lldb/test/API/lang/swift/explicit_modules/simple/TestSwiftExplicitModules_part02.py @@ -27,4 +27,4 @@ def test_import(self): error=True) self.expect("expression import Foundation") self.expect('expression Data([1, 2, 3])', - substrs=["byte"]) + substrs=["3 bytes"]) diff --git a/lldb/test/API/lang/swift/resilience_superclass_other_mod/TestSwiftResilienceSuperclassOtherMod.py b/lldb/test/API/lang/swift/resilience_superclass_other_mod/TestSwiftResilienceSuperclassOtherMod.py index 316ab56f85de2..f2701379fdced 100644 --- a/lldb/test/API/lang/swift/resilience_superclass_other_mod/TestSwiftResilienceSuperclassOtherMod.py +++ b/lldb/test/API/lang/swift/resilience_superclass_other_mod/TestSwiftResilienceSuperclassOtherMod.py @@ -1,9 +1,29 @@ +import os +import subprocess import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * import lldbsuite.test.lldbutil as lldbutil +def _spawn_hang_watchdog(secs): + # rdar://182785830: this test intermittently HANGS (only under CI load) in the + # noclang reflection resolution of `c.v` -- a stored property reached through a + # cross-module resilient *generic* superclass rooted at NSObject. lit just + # SIGKILLs it at the 600s timeout (Exit Code -9) with no backtrace, so we never + # see where it is stuck. This independent child process (GIL-independent, so it + # works even if the hang holds the Python GIL) waits `secs` and then samples the + # possibly-stuck lldb/dotest process, dumping the C++ backtrace to stderr so the + # failing CI run self-documents. Remove before merging. + pid = os.getpid() + out = "/tmp/rdar182785830-hang-%d.txt" % pid + cmd = ("sleep %d; " + "echo '*** rdar182785830 WATCHDOG: c.v unresolved after %ds; sampling pid %d ***' 1>&2; " + "/usr/bin/sample %d 10 1 2>&1 | tee %s 1>&2" + % (secs, secs, pid, pid, out)) + return subprocess.Popen(["/bin/sh", "-c", cmd]) + + class TestSwiftResilienceSuperclassOtherMod(TestBase): @skipEmbeddedSwift @skipUnlessDarwin @@ -14,4 +34,10 @@ def test(self): self, 'break here', lldb.SBFileSpec('ModWithClass.swift'), extra_images=['ModWithClass', 'ModWithSuper']) - self.expect("expression c.v", substrs=["Int", "42"]) + # rdar://182785830 hang instrumentation (see _spawn_hang_watchdog above). + secs = int(os.environ.get("RDAR182785830_WATCHDOG_SECS", "120")) + wd = _spawn_hang_watchdog(secs) + try: + self.expect("expression c.v", substrs=["Int", "42"]) + finally: + wd.terminate() diff --git a/lldb/test/Shell/SwiftREPL/ResilientArray.test b/lldb/test/Shell/SwiftREPL/ResilientArray.test index 6510e57bd805e..90a3ca5abfbfa 100644 --- a/lldb/test/Shell/SwiftREPL/ResilientArray.test +++ b/lldb/test/Shell/SwiftREPL/ResilientArray.test @@ -11,6 +11,6 @@ import Foundation let x : [Data] = [Data([1, 2, 3]), Data([9])] // CHECK: {{x}}: [Foundation.Data] = 2 values { -// CHECK-NEXT: byte -// CHECK-NEXT: byte +// CHECK-NEXT: [0] = 3 bytes +// CHECK-NEXT: [1] = 1 byte // CHECK-NEXT: } diff --git a/lldb/test/Shell/SwiftREPL/ResilientDict.test b/lldb/test/Shell/SwiftREPL/ResilientDict.test index 8d8b7506ed36d..ac46ba54612c0 100644 --- a/lldb/test/Shell/SwiftREPL/ResilientDict.test +++ b/lldb/test/Shell/SwiftREPL/ResilientDict.test @@ -15,13 +15,13 @@ import Foundation let x : [Data:Int] = [Data([1, 2, 3]): 40, Data([9]): 230] // DICT-LABEL: {{x}}: [Foundation.Data : Int] = 2 key/value pairs { // DICT: [{{[0-1]}}] = { -// DICT: byte -// DICT: value = 40 +// DICT: key = 3 bytes +// DICT-NEXT: value = 40 // DICT-NEXT: } let y : [Data:Int] = [Data([1, 2, 3]): 40, Data([9]): 230] // DICT-LABEL: {{y}}: [Foundation.Data : Int] = 2 key/value pairs { // DICT: [{{[0-1]}}] = { -// DICT: byte -// DICT: value = 230 +// DICT: key = 1 byte +// DICT-NEXT: value = 230 // DICT-NEXT: }