Skip to content
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

[SR-15997] Swift 5.6 LLDB breaks Visual Studio Code swift extension #4294

Closed
adam-fowler opened this issue Mar 16, 2022 · 8 comments
Closed
Assignees
Labels
bug Something isn't working LLDB for Swift

Comments

@adam-fowler
Copy link

Previous ID SR-15997
Radar rdar://problem/90360204
Original Reporter @adam-fowler
Type Bug
Status Resolved
Resolution Done
Environment

swift-driver version: 1.45.2 Apple Swift version 5.6 (swiftlang-5.6.0.323.62 clang-1316.0.20.8)

Target: x86_64-apple-macosx12.0

Additional Detail from JIRA
Votes 0
Component/s LLDB for Swift
Labels Bug
Assignee @JDevlieghere
Priority Medium

md5: 94857db454f85bd54d599fa8b9194dde

Issue Description:

With the release of Swift 5.6 debugging tests in the Visual Studio Code swift extension has broken.

When invoking LLDB with a universal binary it returns the following error

error: more than one platform supports this executable (host, remote-macosx), specify an architecture to disambiguate

This can be resolved by adding a --arch command line parameter but I don't have control over the invocation of lldb as that is done by another extension CodeLLDB. This is a different behaviour to the Swift 5.5 lldb which automatically chose a platform based on the system lldb was running on.

To debug tests I need to launch a debug session of `xctest` which is a universal binary. Because of the above this is no longer possible.

If you want to test this inside Visual Studio Code the launch config I setup to run a debug session looks like this

{
    "configurations": [
        {
            "type": "lldb",
            "request": "launch",
            "name": "MyProject Tests",
            "program": "/Applications/Xcode.app/Contents/Developer/usr/bin/xctest",
            "args": [".build/debug/myProjectPackageTests.xctest"],
            "env": {},
            "cwd": "${workspaceFolder:myProject}",
        }
    ]
}
@Lukasa
Copy link

Lukasa commented Mar 16, 2022

@swift-ci create

@adam-fowler
Copy link
Author

I also tried to set the default-arch in lldb and that still produced an error

settings set target.default-arch x86_64
file /Applications/Xcode.app/Contents/Developer/usr/bin/xctest 

@adrian-prantl
Copy link
Member

How exactly is the CodeLLDB plugin launching LLDB? Is it using the API directly or invoking lldb on the command line? In either case it would be important to understand what the plugin is doing exactly to diagnose the problem.

@adrian-prantl
Copy link
Member

Is this always/only happening with the xctest binary? (That one is little special because it works for multiple architectures at the same time).

@adam-fowler
Copy link
Author

CodeLLDB uses the API to launch debug sessions.

It is a general issue with universal applications (multi-arch) as I tested it with my own universal application.

In Swift 5.5 you could run these through lldb (via CLI or API) without being required to specify the architecture. I'm guessing it choose the correct architecture based on the system it was running on . With Swift 5.6 it requires you to specify the architecture.

I'm not sure if this is a bug or feature though. I would expect the default-arch settings to be used though.

@swift-ci
Copy link

Comment by Hristo Hristov (JIRA)

I have the same issue but also in C++ projects. I work on projects some of which are C++ based with Objective-C and Swift and some are Swift. I use Visual Studio Code with the C++ Tools, CMake Tools and C++ Test Mate extensions to build, run and debug the application and unit tests on various macOS and Linux flavors. My C++ project is CMake and Conan based.

% lldb --version
lldb-1316.0.9.41
Apple Swift version 5.6 (swiftlang-5.6.0.323.62 clang-1316.0.20.8)

I filed an issue against the C++ Tools extension first https://github.com/microsoft/vscode-cpptools/issues/9067

So it looks like this is not a Swift only issue. Should I file an issue against LLDB itself?

@JDevlieghere
Copy link
Member

I worked around the issue on the 5.6 branch by disabling the remote-macosx platform: #4144

For the stable/20211026 and 5.7 branch I modified the platform selection logic upstream (https://reviews.llvm.org/D122684) to give priority to the select and host platform: #4147

@swift-ci
Copy link

Comment by Hristo Hristov (JIRA)

@JDevlieghere When is this fix going to be released eventually?

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working LLDB for Swift
Projects
None yet
Development

No branches or pull requests

5 participants