|
| 1 | + |
| 2 | +""" |
| 3 | +Test that stepping works for forward interop |
| 4 | +""" |
| 5 | +from lldbsuite.test.lldbtest import * |
| 6 | +from lldbsuite.test.decorators import * |
| 7 | + |
| 8 | + |
| 9 | +class TestSteppingForwardInterop(TestBase): |
| 10 | + |
| 11 | + @swiftTest |
| 12 | + def test_step_into_function(self): |
| 13 | + """ Test that stepping into a simple C++ function works""" |
| 14 | + self.build() |
| 15 | + self.runCmd('setting set target.experimental.swift-enable-cxx-interop true') |
| 16 | + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( |
| 17 | + self, 'Break here for function', lldb.SBFileSpec('main.swift')) |
| 18 | + |
| 19 | + name = thread.frames[0].GetFunctionName() |
| 20 | + self.assertIn('testFunction', name) |
| 21 | + thread.StepInto() |
| 22 | + name = thread.frames[0].GetFunctionName() |
| 23 | + self.assertIn('cxxFunction', name) |
| 24 | + thread.StepOut() |
| 25 | + name = thread.frames[0].GetFunctionName() |
| 26 | + self.assertIn('testFunction', name) |
| 27 | + |
| 28 | + @swiftTest |
| 29 | + def test_step_over_function(self): |
| 30 | + """ Test that stepping over a simple C++ function works""" |
| 31 | + self.build() |
| 32 | + self.runCmd('setting set target.experimental.swift-enable-cxx-interop true') |
| 33 | + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( |
| 34 | + self, 'Break here for function', lldb.SBFileSpec('main.swift')) |
| 35 | + |
| 36 | + name = thread.frames[0].GetFunctionName() |
| 37 | + self.assertIn('testFunction', name) |
| 38 | + thread.StepOver() |
| 39 | + name = thread.frames[0].GetFunctionName() |
| 40 | + self.assertIn('testFunction', name) |
| 41 | + |
| 42 | + |
| 43 | + @swiftTest |
| 44 | + def test_step_into_method(self): |
| 45 | + """ Test that stepping into a C++ method works""" |
| 46 | + self.build() |
| 47 | + self.runCmd('setting set target.experimental.swift-enable-cxx-interop true') |
| 48 | + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( |
| 49 | + self, 'Break here for method', lldb.SBFileSpec('main.swift')) |
| 50 | + |
| 51 | + name = thread.frames[0].GetFunctionName() |
| 52 | + self.assertIn('testMethod', name) |
| 53 | + thread.StepInto() |
| 54 | + name = thread.frames[0].GetFunctionName() |
| 55 | + self.assertIn('cxxMethod', name) |
| 56 | + thread.StepOut() |
| 57 | + name = thread.frames[0].GetFunctionName() |
| 58 | + self.assertIn('testMethod', name) |
| 59 | + |
| 60 | + @swiftTest |
| 61 | + def test_step_over_method(self): |
| 62 | + """ Test that stepping over a C++ method works""" |
| 63 | + self.build() |
| 64 | + self.runCmd('setting set target.experimental.swift-enable-cxx-interop true') |
| 65 | + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( |
| 66 | + self, 'Break here for method', lldb.SBFileSpec('main.swift')) |
| 67 | + |
| 68 | + name = thread.frames[0].GetFunctionName() |
| 69 | + self.assertIn('testMethod', name) |
| 70 | + thread.StepOver() |
| 71 | + name = thread.frames[0].GetFunctionName() |
| 72 | + self.assertIn('testMethod', name) |
| 73 | + |
| 74 | + @swiftTest |
| 75 | + def test_step_into_constructor(self): |
| 76 | + """ Test that stepping into a simple C++ constructor works""" |
| 77 | + self.build() |
| 78 | + self.runCmd('setting set target.experimental.swift-enable-cxx-interop true') |
| 79 | + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( |
| 80 | + self, 'Break here for constructor', lldb.SBFileSpec('main.swift')) |
| 81 | + |
| 82 | + # FIXME: this step over shouldn't be necessary (rdar://105569287) |
| 83 | + thread.StepOver() |
| 84 | + |
| 85 | + name = thread.frames[0].GetFunctionName() |
| 86 | + self.assertIn('testContructor', name) |
| 87 | + thread.StepInto() |
| 88 | + name = thread.frames[0].GetFunctionName() |
| 89 | + self.assertIn('ClassWithConstructor::ClassWithConstructor', name) |
| 90 | + thread.StepOut() |
| 91 | + name = thread.frames[0].GetFunctionName() |
| 92 | + self.assertIn('testContructor', name) |
| 93 | + |
| 94 | + @swiftTest |
| 95 | + def test_step_over_constructor(self): |
| 96 | + """ Test that stepping over a simple C++ constructor works""" |
| 97 | + self.build() |
| 98 | + self.runCmd('setting set target.experimental.swift-enable-cxx-interop true') |
| 99 | + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( |
| 100 | + self, 'Break here for constructor', lldb.SBFileSpec('main.swift')) |
| 101 | + |
| 102 | + # FIXME: this step over shouldn't be necessary (rdar://105569287) |
| 103 | + thread.StepOver() |
| 104 | + |
| 105 | + name = thread.frames[0].GetFunctionName() |
| 106 | + self.assertIn('testContructor', name) |
| 107 | + thread.StepOver() |
| 108 | + name = thread.frames[0].GetFunctionName() |
| 109 | + self.assertIn('testContructor', name) |
| 110 | + |
| 111 | + @swiftTest |
| 112 | + def test_step_into_extension(self): |
| 113 | + """ Test that stepping into a C++ function defined in an extension works""" |
| 114 | + self.build() |
| 115 | + self.runCmd('setting set target.experimental.swift-enable-cxx-interop true') |
| 116 | + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( |
| 117 | + self, 'Break here for extension', lldb.SBFileSpec('main.swift')) |
| 118 | + |
| 119 | + name = thread.frames[0].GetFunctionName() |
| 120 | + self.assertIn('testClassWithExtension', name) |
| 121 | + thread.StepInto() |
| 122 | + name = thread.frames[0].GetFunctionName() |
| 123 | + self.assertIn('definedInExtension', name) |
| 124 | + thread.StepOut() |
| 125 | + name = thread.frames[0].GetFunctionName() |
| 126 | + self.assertIn('testClassWithExtension', name) |
| 127 | + |
| 128 | + @swiftTest |
| 129 | + def test_step_over_extension(self): |
| 130 | + """ Test that stepping over a C++ function defined in an extension works""" |
| 131 | + self.build() |
| 132 | + self.runCmd('setting set target.experimental.swift-enable-cxx-interop true') |
| 133 | + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( |
| 134 | + self, 'Break here for extension', lldb.SBFileSpec('main.swift')) |
| 135 | + |
| 136 | + name = thread.frames[0].GetFunctionName() |
| 137 | + self.assertIn('testClassWithExtension', name) |
| 138 | + thread.StepOver() |
| 139 | + name = thread.frames[0].GetFunctionName() |
| 140 | + self.assertIn('testClassWithExtension', name) |
| 141 | + |
| 142 | + @swiftTest |
| 143 | + def test_step_into_call_operator(self): |
| 144 | + """ Test that stepping into a C++ call operator works""" |
| 145 | + self.build() |
| 146 | + self.runCmd('setting set target.experimental.swift-enable-cxx-interop true') |
| 147 | + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( |
| 148 | + self, 'Break here for call operator', lldb.SBFileSpec('main.swift')) |
| 149 | + |
| 150 | + name = thread.frames[0].GetFunctionName() |
| 151 | + self.assertIn('testCallOperator', name) |
| 152 | + thread.StepInto() |
| 153 | + name = thread.frames[0].GetFunctionName() |
| 154 | + self.assertIn('ClassWithCallOperator::operator()()', name) |
| 155 | + thread.StepOut() |
| 156 | + name = thread.frames[0].GetFunctionName() |
| 157 | + self.assertIn('testCallOperator', name) |
| 158 | + |
| 159 | + @swiftTest |
| 160 | + def test_step_over_call_operator(self): |
| 161 | + """ Test that stepping over a C++ call operator works""" |
| 162 | + self.build() |
| 163 | + self.runCmd('setting set target.experimental.swift-enable-cxx-interop true') |
| 164 | + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( |
| 165 | + self, 'Break here for call operator', lldb.SBFileSpec('main.swift')) |
| 166 | + |
| 167 | + name = thread.frames[0].GetFunctionName() |
| 168 | + self.assertIn('testCallOperator', name) |
| 169 | + thread.StepOver() |
| 170 | + name = thread.frames[0].GetFunctionName() |
| 171 | + self.assertIn('testCallOperator', name) |
| 172 | + |
0 commit comments