Skip to content

[lldb] Restore Playground functionality #10946

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
merged 2 commits into from
Jul 2, 2025

Conversation

adrian-prantl
Copy link

Playgrounds is setting a breakpoint in the PlaygroundStub executable,
which has no debug info and is implemented in C. Before
b5a1d34,
LLDB would have done an
expensive and fragile scan through all images to find any Swift
modules and make them available. We stopped doing that because it
caused performance and correctness problems in Objective-C code that
interacted with Swift. However, avoiding the global scan also breaks
Playground's ability to find auxiliary source code.

This patch restores the original behavior when
SwiftASTContextForExpressions is initialized for a Playground only.

rdar://154373965

@adrian-prantl adrian-prantl requested a review from a team as a code owner July 2, 2025 15:57
@adrian-prantl
Copy link
Author

@swift-ci test

The result of an Objective-C expression can be a Swift
ValueObject. This means that `po foo` in Objective-C may run a Swift
expression to print the object description of the result of the
Objective-C expression `foo`. That expression has very few
dependencies:

```
Swift._DebuggerSupport.stringForPrintObject(Swift.unsafeBitCast(0x001234, to: AnyObject.self))
```

To avoid scanning potentially incompatible compiler flags and/or doing
implicit imports in anotherwise explicitly built project, this patch
ensures that one SwiftASTContext per triple is created, with no other
contextual information. This makes `po` in ObjC much faster and
reliable, the downside of this is that

```expr -l Swift -- import ModuleName```

will only work reliably for SDK modules outside of Swift frames.

rdar://153332037
Playgrounds is setting a breakpoint in the PlaygroundStub executable,
which has no debug info and is implemented in C. Before
b5a1d34, LLDB would have done an
expensive and fragile scan through all images to find any Swift
modules and make them available. We stopped doing that because it
caused performance and correctness problems in Objective-C code that
interacted with Swift. However, avoiding the global scan also breaks
Playground's ability to find auxiliary source code.

This patch restores the original behavior when
SwiftASTContextForExpressions is initialized for a Playground only.

rdar://154373965
@adrian-prantl
Copy link
Author

@swift-ci test

@adrian-prantl adrian-prantl merged commit 46256c8 into swiftlang:swift/release/6.2 Jul 2, 2025
3 checks passed
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