Skip to content

[Cherry-pick into next] [lldb] Initialize a shared, blank SwiftASTContext in Objective-C frames #10879

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

adrian-prantl
Copy link

commit b5a1d34ec8a4a21da6bc0b169884f8e536aeb6dd
Author: Adrian Prantl <aprantl@apple.com>
Date:   Mon Jun 16 17:30:42 2025 -0700

    [lldb] Initialize a shared, blank SwiftASTContext in Objective-C frames
    
    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

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
(cherry picked from commit b5a1d34)
@adrian-prantl adrian-prantl merged commit 84b978d into swiftlang:next Jun 20, 2025
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.

None yet

1 participant