swiftlang / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies. This fork is used to manage Swift’s stable releases of Clang as well as support the Swift project.
https://llvm.org
Other
1.12k stars 331 forks source link

[cherry-pick][lldb][swift] Filter Q funclets when setting breakpoints #9125

Closed felipepiovezan closed 2 months ago

felipepiovezan commented 2 months ago

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.

(cherry picked from commit 9158af037639c56aba557750851e6e2d4204b2b1)