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-10822] Swift 5.x LLDB fails on Linux with "error: failed to get module 'MyApp' from AST context" #4565

Open
swift-ci opened this issue Jun 2, 2019 · 11 comments
Labels

Comments

@swift-ci
Copy link

swift-ci commented Jun 2, 2019

Previous ID SR-10822
Radar None
Original Reporter ewconnell (JIRA User)
Type Bug

Attachment: Download

Environment

Ubuntu 16.04, 18.04, or the official swift docker images for Linux. They all fail.

Additional Detail from JIRA
Votes 1
Component/s LLDB for Swift
Labels Bug, 5.0Regression
Assignee @neonichu
Priority Medium

md5: 0a2586239d4df0ce1604b3fbefb62b96

Issue Description:

Using any version of Swift 5.x on Ubuntu 18.04 (and 16.04) I can run and step though an app, but I am unable to examine any variables in lldb. It just bombs with "failed to get module 'MyApp' from AST context".

The Swift 4.2 toolchain works fine.

I tried the Swift latest docker image for ubuntu 18.04 and it fails also, which means it has nothing to do with my installation.

struct MyStruct {
    var a: Int = 0
    var b: Int = 42
}
 
var data = MyStruct()
  
print("Hello, world! data: (data)")  // set a breakpoint here and try (lldb) po data 

This is blocking all work for my company. Please fix this quickly or provide a workaround.

Thanks, Ed

@belkadan
Copy link

belkadan commented Jun 3, 2019

cc @dcci

@dcci
Copy link
Mannequin

dcci mannequin commented Jun 3, 2019

This is something that @adrian-prantl knows best.

@adrian-prantl
Copy link
Member

Can you add "log enable lldb types -f /tmp/types.log" to ~/.lldbinit, relaunch lldb, reproduce the issue and upload /tmp/types.log? It will contain all the info we need to diagnose the issue.

@swift-ci
Copy link
Author

swift-ci commented Jun 4, 2019

Comment by Edward Connell (JIRA)

Okay done!

Hey thanks for checking this out.

@adrian-prantl
Copy link
Member

> lldb Found 0 AST file data entries for library: /home/ed/hello/.build/debug/hello.

> lldb ((SwiftASTContext*)0x24e55f0)->GetModule('hello')
> lldb ((SwiftASTContext*)0x24e55f0)->GetModule('hello') – failed with no error

This indicates that LLDB may have had trouble finding the .swiftmodule for "hello". How did you compile your program?

@adrian-prantl
Copy link
Member

Can you paste the swiftc invocation that you used for hello and then also append `-###` at the end and paste the result of that?

@swift-ci
Copy link
Author

swift-ci commented Jun 4, 2019

Comment by Edward Connell (JIRA)

I just added a terminal transcript from start to finish. I use the swift package manager to create the project. On line 16, I gedit "main.swift" and paste in the following contents.

struct MyStruct{
    var a: Int = 0
    var b: Int = 42
}

var data = MyStruct()
  
print("Hello, world! data: (data)")  // set a breakpoint here

break on line 8 and try to examine "data", it bombs.

@adrian-prantl
Copy link
Member

This may be the known issue of the Swift package manager not performing the modulewrap action. I'll need to try and reproduce to confirm.

When you compile hello.swift with swiftc directly (not using swiftopm), does debugging work?

@swift-ci
Copy link
Author

swift-ci commented Jun 4, 2019

Comment by Edward Connell (JIRA)

I just tried it. Yes, using "swiftc -g main.swift" debugging works. So it's an SPM issue. I guess I will need to use an external build system like CMake. I really appreciate you helping me with this. I have to say, I am really surprised Apple would allow a product release without testing one of the most obvious features like build and debug. I also can't believe it hasn't already been fixed. Anyway, thank you so much for your help.

Have a great day, Ed

@adrian-prantl
Copy link
Member

@neonichu do you have an existing swiftpm JIRA ticked this should be duped to? I think the problem here is that similar how on macOS swiftpm doesn't add -add-ast-path to the linker invocation, it (presumable) also doesn't invoke the modulewrap action on Linux.

@adrian-prantl
Copy link
Member

(This could actually make for a nice starter bug?)

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 7, 2022
@neonichu neonichu removed their assignment Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants