Skip to content

[lldb][swift] Filter Q funclets when setting breakpoints #9112

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

Conversation

felipepiovezan
Copy link

@felipepiovezan felipepiovezan commented Aug 14, 2024

rdar://123391705

These funclets only serve to task_dealloc previously allocated tasks when returning from an async call, and immediately task_switch to the next await-suspend ("Y") funclet (which contains real user code).

By not filtering out these funclets, any breakpoint on a line with an async call will cause execution to pause 3 times: once before the call, twice when "returning" from the call, which makes for a confusing experience.

The patch does the filtering on BreakpointResolver::SetSCMatchesByLine, which is the common code between BreakpointResolverFileLine and BreakpointResolverFileRegex.

We also considered changing the debug line information in any of the many different lowering stages the swift compiler, but this turned out to be very complex to do in a targeted way; more often than not, a handful of early-IR coroutine instructions get expanded into multiple function clones, all inheriting the same debug line information. The current approach also has the advantaged of being easily reversible if we decide to do so.

These funclets only serve to `task_dealloc` previously allocated tasks when
returning from an async call, and immediately `task_switch` to the next
await-suspend funclet (which contains real user code).

By not filtering out these funclets, any breakpoint on a line with an async call
will cause execution to pause 3 times: once before the call, twice when
"returning" from the call, which makes for a confusing experience.

The patch does the filtering on `BreakpointResolver::SetSCMatchesByLine`, which
is the common code between BreakpointResolverFileLine and
BreakpointResolverFileRegex.

We also considered changing the debug line information in any of the many
different lowering stages the swift compiler, but this turned out to be very
complex to do in a targeted way; more often than not, a handful of early-IR
coroutine instructions get expanded into multiple function clones, all
inheriting the same debug line information. The current approach also has the
advantaged of being easily reversible if we decide to do so.
@felipepiovezan felipepiovezan merged commit da8a0ea into swiftlang:stable/20240723 Aug 15, 2024
@felipepiovezan felipepiovezan deleted the felipe/filter_q_funclets branch August 15, 2024 17:08
felipepiovezan added a commit to felipepiovezan/llvm-project that referenced this pull request Feb 11, 2025
With [1], stepping should work reliably even in the multithreaded case.
With [2], the issue of multiple breakpoints on the same should no longer
affect this test.

[1]: swiftlang#9839
[2]: swiftlang#9112
felipepiovezan added a commit that referenced this pull request Feb 11, 2025
With [1], stepping should work reliably even in the multithreaded case.
With [2], the issue of multiple breakpoints on the same should no longer
affect this test.

[1]: #9839
[2]: #9112

(cherry picked from commit 4ab6819)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants