|
| 1 | +import lldb |
| 2 | +import lldbsuite.test.lldbutil as lldbutil |
| 3 | +from lldbsuite.test.lldbtest import * |
| 4 | +from lldbsuite.test.decorators import * |
| 5 | + |
| 6 | + |
| 7 | +class TestCase(TestBase): |
| 8 | + |
| 9 | + def setUp(self): |
| 10 | + TestBase.setUp(self) |
| 11 | + self.build() |
| 12 | + self.runCmd("settings set target.experimental.swift-use-new-po true") |
| 13 | + |
| 14 | + self.log = self.getBuildArtifact("expr.log") |
| 15 | + self.runCmd(f"log enable lldb expr -f {self.log}") |
| 16 | + |
| 17 | + def _filecheck(self, key): |
| 18 | + self.filecheck(f"platform shell cat {self.log}", __file__, f"-check-prefix=CHECK-{key}") |
| 19 | + |
| 20 | + @swiftTest |
| 21 | + def test_int(self): |
| 22 | + lldbutil.run_to_source_breakpoint( |
| 23 | + self, "break int", lldb.SBFileSpec("main.swift") |
| 24 | + ) |
| 25 | + self.expect("po value", substrs=["2025"]) |
| 26 | + self._filecheck("INT") |
| 27 | + # CHECK-INT: stringForPrintObject(UnsafeRawPointer(bitPattern: {{[0-9]+}}), mangledTypeName: "SiD") |
| 28 | + |
| 29 | + @swiftTest |
| 30 | + def test_string(self): |
| 31 | + lldbutil.run_to_source_breakpoint( |
| 32 | + self, "break string", lldb.SBFileSpec("main.swift") |
| 33 | + ) |
| 34 | + self.expect("po value", substrs=["Po"]) |
| 35 | + self._filecheck("STRING") |
| 36 | + # CHECK-STRING: stringForPrintObject(UnsafeRawPointer(bitPattern: {{[0-9]+}}), mangledTypeName: "SSD") |
| 37 | + |
| 38 | + @swiftTest |
| 39 | + def test_struct(self): |
| 40 | + lldbutil.run_to_source_breakpoint( |
| 41 | + self, "break struct", lldb.SBFileSpec("main.swift") |
| 42 | + ) |
| 43 | + self.expect("po value", substrs=["▿ Struct"]) |
| 44 | + self._filecheck("STRUCT") |
| 45 | + # CHECK-STRUCT: stringForPrintObject(UnsafeRawPointer(bitPattern: {{[0-9]+}}), mangledTypeName: "1a6StructVD") |
| 46 | + |
| 47 | + @swiftTest |
| 48 | + def test_class(self): |
| 49 | + lldbutil.run_to_source_breakpoint( |
| 50 | + self, "break class", lldb.SBFileSpec("main.swift") |
| 51 | + ) |
| 52 | + self.expect("po value", substrs=["<Class: 0x"]) |
| 53 | + self._filecheck("CLASS") |
| 54 | + # CHECK-CLASS: stringForPrintObject(UnsafeRawPointer(bitPattern: {{[0-9]+}}), mangledTypeName: "1a5ClassCD") |
| 55 | + |
| 56 | + @swiftTest |
| 57 | + def test_enum(self): |
| 58 | + lldbutil.run_to_source_breakpoint( |
| 59 | + self, "break enum", lldb.SBFileSpec("main.swift") |
| 60 | + ) |
| 61 | + self.expect("po value", substrs=["▿ Enum"]) |
| 62 | + self._filecheck("ENUM") |
| 63 | + # CHECK-ENUM: stringForPrintObject(UnsafeRawPointer(bitPattern: {{.*}}), mangledTypeName: "1a4EnumOD") |
| 64 | + |
| 65 | + @swiftTest |
| 66 | + def test_generic_struct(self): |
| 67 | + lldbutil.run_to_source_breakpoint( |
| 68 | + self, "break generic struct", lldb.SBFileSpec("main.swift") |
| 69 | + ) |
| 70 | + self.expect("po value", substrs=["▿ GenericStruct<String>"]) |
| 71 | + self._filecheck("GEN-STRUCT") |
| 72 | + # CHECK-GEN-STRUCT: stringForPrintObject(UnsafeRawPointer(bitPattern: {{[0-9]+}}), mangledTypeName: "1a13GenericStructVySSGD") |
| 73 | + |
| 74 | + @swiftTest |
| 75 | + def test_generic_class(self): |
| 76 | + lldbutil.run_to_source_breakpoint( |
| 77 | + self, "break generic class", lldb.SBFileSpec("main.swift") |
| 78 | + ) |
| 79 | + self.expect("po value", substrs=["<GenericClass<String>: 0x"]) |
| 80 | + self._filecheck("GEN-CLASS") |
| 81 | + # CHECK-GEN-CLASS: stringForPrintObject(UnsafeRawPointer(bitPattern: {{[0-9]+}}), mangledTypeName: "1a12GenericClassCySSGD") |
| 82 | + |
| 83 | + @swiftTest |
| 84 | + def test_generic_enum(self): |
| 85 | + lldbutil.run_to_source_breakpoint( |
| 86 | + self, "break generic enum", lldb.SBFileSpec("main.swift") |
| 87 | + ) |
| 88 | + self.expect("po value", substrs=["▿ GenericEnum<String>"]) |
| 89 | + self._filecheck("GEN-ENUM") |
| 90 | + # CHECK-GEN-ENUM: stringForPrintObject(UnsafeRawPointer(bitPattern: {{.*}}), mangledTypeName: "1a11GenericEnumOySSGD") |
| 91 | + |
| 92 | + @swiftTest |
| 93 | + def test_described_struct(self): |
| 94 | + lldbutil.run_to_source_breakpoint( |
| 95 | + self, "break described struct", lldb.SBFileSpec("main.swift") |
| 96 | + ) |
| 97 | + self.expect("po value", substrs=["DescribedStruct"]) |
| 98 | + self._filecheck("DESC-STRUCT") |
| 99 | + # CHECK-DESC-STRUCT: stringForPrintObject(UnsafeRawPointer(bitPattern: {{[0-9]+}}), mangledTypeName: "1a15DescribedStructVD") |
| 100 | + |
| 101 | + @swiftTest |
| 102 | + def test_described_class(self): |
| 103 | + lldbutil.run_to_source_breakpoint( |
| 104 | + self, "break described class", lldb.SBFileSpec("main.swift") |
| 105 | + ) |
| 106 | + self.expect("po value", substrs=["DescribedClass"]) |
| 107 | + self._filecheck("DESC-CLASS") |
| 108 | + # CHECK-DESC-CLASS: stringForPrintObject(UnsafeRawPointer(bitPattern: {{[0-9]+}}), mangledTypeName: "1a14DescribedClassCD") |
| 109 | + |
| 110 | + @swiftTest |
| 111 | + def test_described_enum(self): |
| 112 | + lldbutil.run_to_source_breakpoint( |
| 113 | + self, "break described enum", lldb.SBFileSpec("main.swift") |
| 114 | + ) |
| 115 | + self.expect("po value", substrs=["DescribedEnum"]) |
| 116 | + self._filecheck("DESC-ENUM") |
| 117 | + # CHECK-DESC-ENUM: stringForPrintObject(UnsafeRawPointer(bitPattern: {{.*}}), mangledTypeName: "1a13DescribedEnumOD") |
0 commit comments