|
| 1 | +import lldb |
| 2 | +from lldbsuite.test.decorators import * |
| 3 | +import lldbsuite.test.lldbtest as lldbtest |
| 4 | +import lldbsuite.test.lldbutil as lldbutil |
| 5 | +import unittest2 |
| 6 | + |
| 7 | + |
| 8 | +class TestSwiftAsyncBacktraceLocals(lldbtest.TestBase): |
| 9 | + |
| 10 | + mydir = lldbtest.TestBase.compute_mydir(__file__) |
| 11 | + |
| 12 | + @swiftTest |
| 13 | + @skipIf(oslist=['windows', 'linux']) |
| 14 | + def test(self): |
| 15 | + """Test async unwind""" |
| 16 | + self.build() |
| 17 | + src = lldb.SBFileSpec('main.swift') |
| 18 | + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( |
| 19 | + self, 'main breakpoint', src) |
| 20 | + |
| 21 | + start_bkpt = target.BreakpointCreateBySourceRegex('function start', src, None) |
| 22 | + end_bkpt = target.BreakpointCreateBySourceRegex('end iteration', src, None) |
| 23 | + |
| 24 | + if self.TraceOn(): |
| 25 | + self.runCmd("bt all") |
| 26 | + |
| 27 | + for n in range(10): |
| 28 | + lldbutil.continue_to_breakpoint(process, start_bkpt) |
| 29 | + for f in range(n+1): |
| 30 | + frame = thread.GetFrameAtIndex(f) |
| 31 | + self.assertIn("fibonacci", frame.GetFunctionName(), |
| 32 | + "Redundantly confirm that we're stopped in fibonacci()") |
| 33 | + if f == 0: |
| 34 | + # Get arguments (arguments, locals, statics, in_scope_only) |
| 35 | + args = frame.GetVariables(True, False, False, True) |
| 36 | + self.assertEqual(len(args), 1, "Found one argument") |
| 37 | + self.assertEqual(args[0].GetName(), "n", "Found n argument") |
| 38 | + self.assertEqual(args[0].GetValue(), str(10-n), "n has correct value") |
| 39 | + self.assertIn("Main.main", thread.GetFrameAtIndex(n+1).GetFunctionName()) |
| 40 | + |
| 41 | + lldbutil.continue_to_breakpoint(process, end_bkpt) |
| 42 | + frame = thread.GetFrameAtIndex(0) |
| 43 | + args = frame.GetVariables(True, False, False, True) |
| 44 | + self.assertEqual(len(args), 1, "Found one argument") |
| 45 | + self.assertEqual(args[0].GetName(), "n", "Found n argument") |
| 46 | + self.assertEqual(args[0].GetValue(), str(1), "n has correct value") |
| 47 | + |
| 48 | + lldbutil.continue_to_breakpoint(process, end_bkpt) |
| 49 | + frame = thread.GetFrameAtIndex(0) |
| 50 | + args = frame.GetVariables(True, False, False, True) |
| 51 | + self.assertEqual(len(args), 1, "Found one argument") |
| 52 | + self.assertEqual(args[0].GetName(), "n", "Found n argument") |
| 53 | + self.assertEqual(args[0].GetValue(), str(0), "n has correct value") |
0 commit comments