forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 351
[lldb] Use unique line count in swift_task_switch logic #6839
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
adrian-prantl
merged 1 commit into
swift/release/5.9
from
dl/lldb-use-unique-line-count-in-swift_task_switch-logic
May 23, 2023
Merged
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions
3
lldb/test/API/lang/swift/async/stepping/step-in/task-switch/Makefile
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 |
35 changes: 35 additions & 0 deletions
35
lldb/test/API/lang/swift/async/stepping/step-in/task-switch/TestSwiftTaskSwitch.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,35 @@ | ||
| import lldb | ||
| from lldbsuite.test.decorators import * | ||
| import lldbsuite.test.lldbtest as lldbtest | ||
| import lldbsuite.test.lldbutil as lldbutil | ||
|
|
||
|
|
||
| class TestCase(lldbtest.TestBase): | ||
| @swiftTest | ||
| @skipIf(oslist=["windows", "linux"]) | ||
| def test(self): | ||
| """Test conditions for async step-in.""" | ||
| self.build() | ||
|
|
||
| src = lldb.SBFileSpec("main.swift") | ||
| target, _, thread, _ = lldbutil.run_to_source_breakpoint(self, "await f()", src) | ||
| self.assertEqual(thread.frame[0].function.mangled, "$s1a5entryO4mainyyYaFZ") | ||
|
|
||
| function = target.FindFunctions("$s1a5entryO4mainyyYaFZTQ0_")[0].function | ||
| instructions = list(function.GetInstructions(target)) | ||
|
|
||
| # Expected to be a trampoline that tail calls `swift_task_switch`. | ||
| self.assertIn("swift_task_switch", instructions[-1].GetComment(target)) | ||
|
|
||
| # Using the line table, build a set of the non-zero line numbers for | ||
| # this this function - and verify that there is exactly one line. | ||
| lines = {inst.addr.line_entry.line for inst in instructions} | ||
| lines.remove(0) | ||
| self.assertEqual(lines, {3}) | ||
|
|
||
| # Required for builds that have debug info. | ||
| self.runCmd("settings set target.process.thread.step-avoid-libraries libswift_Concurrency.dylib") | ||
| thread.StepInto() | ||
| frame = thread.frame[0] | ||
| # Step in from `main` should progress through to `f`. | ||
| self.assertEqual(frame.name, "a.f() async -> Swift.Int") | ||
10 changes: 10 additions & 0 deletions
10
lldb/test/API/lang/swift/async/stepping/step-in/task-switch/main.swift
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,10 @@ | ||
| @main enum entry { | ||
| static func main() async { | ||
| let x = await f() | ||
| print(x) | ||
| } | ||
| } | ||
|
|
||
| func f() async -> Int { | ||
| return 30 | ||
| } |
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.
can you assert that function is non-null? Will be easier to debug that way.
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.
#6908