Skip to content

Commit 3cd7dc2

Browse files
[lldb][nfc] Format test and add helper function
1 parent cb50c86 commit 3cd7dc2

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

lldb/test/API/lang/swift/async/frame/variables_multiple_frames/TestSwiftAsyncFrameVarMultipleFrames.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,28 @@ class TestCase(lldbtest.TestBase):
88

99
mydir = lldbtest.TestBase.compute_mydir(__file__)
1010

11+
def read_ptr_from_memory(self, process, addr):
12+
error = lldb.SBError()
13+
value = process.ReadPointerFromMemory(addr, error)
14+
self.assertSuccess(error, "Failed to read memory")
15+
return value
16+
1117
# Check that the CFA chain is correctly built
1218
def check_cfas(self, async_frames, process):
1319
async_cfas = list(map(lambda frame: frame.GetCFA(), async_frames))
1420
expected_cfas = [async_cfas[0]]
1521
# The CFA chain ends in nullptr.
1622
while expected_cfas[-1] != 0:
17-
error = lldb.SBError()
18-
expected_cfas.append(
19-
process.ReadPointerFromMemory(expected_cfas[-1], error)
20-
)
21-
self.assertSuccess(error, "Managed to read cfa memory")
23+
expected_cfas.append(self.read_ptr_from_memory(process, expected_cfas[-1]))
2224

2325
self.assertEqual(async_cfas, expected_cfas[:-1])
2426

2527
def check_pcs(self, async_frames, process, target):
2628
for idx, frame in enumerate(async_frames[:-1]):
2729
# Read the continuation pointer from the second field of the CFA.
28-
error = lldb.SBError()
29-
continuation_ptr = process.ReadPointerFromMemory(
30-
frame.GetCFA() + target.addr_size, error
30+
continuation_ptr = self.read_ptr_from_memory(
31+
process, frame.GetCFA() + target.addr_size
3132
)
32-
self.assertSuccess(error, "Managed to read context memory")
3333

3434
# The PC of the previous frame should be the continuation pointer
3535
# with the funclet's prologue skipped.
@@ -39,7 +39,7 @@ def check_pcs(self, async_frames, process, target):
3939

4040

4141
def check_variables(self, async_frames, expected_values):
42-
for (frame, expected_value) in zip(async_frames, expected_values):
42+
for frame, expected_value in zip(async_frames, expected_values):
4343
myvar = frame.FindVariable("myvar")
4444
lldbutil.check_variable(self, myvar, False, value=expected_value)
4545

0 commit comments

Comments
 (0)