Skip to content

Commit 8181ec4

Browse files
authored
[lldb] Enable formatter for ThrowingTaskGroup (#10242)
Update the type name regex to support `ThrowingTaskGroup`. Adds equivalent tests.
1 parent c115016 commit 8181ec4

File tree

3 files changed

+42
-7
lines changed

3 files changed

+42
-7
lines changed

lldb/source/Plugins/Language/Swift/SwiftLanguage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ static void LoadSwiftFormatters(lldb::TypeCategoryImplSP swift_category_sp) {
432432
swift_category_sp,
433433
lldb_private::formatters::swift::TaskGroupSyntheticFrontEndCreator,
434434
"Swift.TaskGroup synthetic children",
435-
ConstString("^Swift\\.TaskGroup<.+>"), synth_flags, true);
435+
ConstString("^Swift\\.(Throwing)?TaskGroup<.+>"), synth_flags, true);
436436

437437
AddCXXSummary(
438438
swift_category_sp, lldb_private::formatters::swift::Bool_SummaryProvider,

lldb/test/API/lang/swift/async/taskgroups/TestSwiftTaskGroupSynthetic.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,24 @@
77
class TestCase(TestBase):
88

99
@swiftTest
10-
def test_value_printing(self):
10+
def test_print_task_group(self):
1111
"""Print a TaskGroup and verify its children."""
1212
self.build()
1313
lldbutil.run_to_source_breakpoint(
14-
self, "break here", lldb.SBFileSpec("main.swift")
14+
self, "break here TaskGroup", lldb.SBFileSpec("main.swift")
1515
)
16+
self.do_test_print()
17+
18+
@swiftTest
19+
def test_print_throwing_task_group(self):
20+
"""Print a ThrowingTaskGroup and verify its children."""
21+
self.build()
22+
lldbutil.run_to_source_breakpoint(
23+
self, "break here ThrowingTaskGroup", lldb.SBFileSpec("main.swift")
24+
)
25+
self.do_test_print()
26+
27+
def do_test_print(self):
1628
self.expect(
1729
"v group",
1830
substrs=[
@@ -32,12 +44,24 @@ def test_value_printing(self):
3244
)
3345

3446
@swiftTest
35-
def test_value_api(self):
47+
def test_api_task_group(self):
3648
"""Verify a TaskGroup contains its expected children."""
3749
self.build()
3850
_, process, _, _ = lldbutil.run_to_source_breakpoint(
39-
self, "break here", lldb.SBFileSpec("main.swift")
51+
self, "break here TaskGroup", lldb.SBFileSpec("main.swift")
4052
)
53+
self.do_test_api(process)
54+
55+
@swiftTest
56+
def test_api_task_group(self):
57+
"""Verify a ThrowingTaskGroup contains its expected children."""
58+
self.build()
59+
_, process, _, _ = lldbutil.run_to_source_breakpoint(
60+
self, "break here ThrowingTaskGroup", lldb.SBFileSpec("main.swift")
61+
)
62+
self.do_test_api(process)
63+
64+
def do_test_api(self, process):
4165
thread = process.GetSelectedThread()
4266
frame = thread.GetSelectedFrame()
4367
group = frame.FindVariable("group")

lldb/test/API/lang/swift/async/taskgroups/main.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,23 @@
33
await withTaskGroup { group in
44
for _ in 0..<3 {
55
group.addTask {
6-
try? await Task.sleep(for: .seconds(300))
6+
try? await Task.sleep(for: .seconds(1))
77
}
88
}
99

10-
print("break here")
10+
print("break here TaskGroup")
1111
for await _ in group {}
1212
}
13+
14+
try? await withThrowingTaskGroup { group in
15+
for _ in 0..<3 {
16+
group.addTask {
17+
try await Task.sleep(for: .seconds(1))
18+
}
19+
}
20+
21+
print("break here ThrowingTaskGroup")
22+
for try await _ in group {}
23+
}
1324
}
1425
}

0 commit comments

Comments
 (0)