forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 341
[lldb] Add synthetic formatter for Swift.TaskGroup #10143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kastiglione
merged 8 commits into
stable/20240723
from
dl/lldb-Add-synthetic-formatter-for-Swift.TaskGroup
Mar 4, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
94057a1
[lldb] Add synthetic formatter for Swift.TaskGroup
kastiglione 6df9e55
Add TestTaskGroupSynthetic.py
kastiglione 0d6142b
Refactoring and cleanups
kastiglione 40a2e1e
Rename test to use TestSwift prefix
kastiglione 096e08d
NULL -> nullptr
kastiglione a3b981a
Check and support 64bit
kastiglione 31845cf
Add test using SB API
kastiglione f4c6c13
Fix StringRef parsing logic
kastiglione File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SWIFT_SOURCES := main.swift | ||
SWIFTFLAGS_EXTRAS := -parse-as-library | ||
include Makefile.rules |
43 changes: 43 additions & 0 deletions
43
lldb/test/API/lang/swift/async/taskgroups/TestSwiftTaskGroupSynthetic.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import lldb | ||
from lldbsuite.test.decorators import * | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test import lldbutil | ||
|
||
|
||
class TestCase(TestBase): | ||
|
||
@swiftTest | ||
def test_value_printing(self): | ||
"""Print a TaskGroup and verify its children.""" | ||
self.build() | ||
lldbutil.run_to_source_breakpoint( | ||
self, "break here", lldb.SBFileSpec("main.swift") | ||
) | ||
self.expect( | ||
"v group", | ||
substrs=[ | ||
"[0] = {", | ||
"isGroupChildTask = true", | ||
"[1] = {", | ||
"isGroupChildTask = true", | ||
"[2] = {", | ||
"isGroupChildTask = true", | ||
], | ||
) | ||
|
||
@swiftTest | ||
def test_value_api(self): | ||
"""Verify a TaskGroup contains its expected children.""" | ||
self.build() | ||
_, process, _, _ = lldbutil.run_to_source_breakpoint( | ||
self, "break here", lldb.SBFileSpec("main.swift") | ||
) | ||
thread = process.GetSelectedThread() | ||
frame = thread.GetSelectedFrame() | ||
group = frame.FindVariable("group") | ||
self.assertEqual(group.num_children, 3) | ||
for task in group: | ||
self.assertEqual(str(task), str(group.GetChildMemberWithName(task.name))) | ||
self.assertEqual( | ||
task.GetChildMemberWithName("isGroupChildTask").summary, "true" | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@main struct Main { | ||
static func main() async { | ||
await withTaskGroup { group in | ||
for _ in 0..<3 { | ||
group.addTask { | ||
try? await Task.sleep(for: .seconds(300)) | ||
} | ||
} | ||
|
||
print("break here") | ||
for await _ in group {} | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this probably covers it, It would be slightly better to test GetChildWithName/GetChildAtIndex/GetNumChildren separately, since they are implemented separately, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a new test in 31845cf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, I had a StringRef bug in
GetIndexOfChildWithName