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-6954] Interactive lldb debugging does not work on Linux (regression in Swift 4.1) #4499
Comments
@swift-ci create |
While I'm investigating the root cause, as a workaround you can pass `-Xcc -isystem -Xcc $PATH_TO/lib/swift/clang/include` to swiftc during compilation. |
Comment by Mason Mark (JIRA) Thank you @adrian-prantl, that is helpful, and allowed me to get lldb working in the simple test program referenced above. However, the real project from which that was extracted builds with (For completeness, I append the examples below.) Works when using swiftc directly: developer@ubuntu:~/SORACOM/lldb-failure-demo-swift-4.1-beta/Sources/lldb-failure-demo$ swiftc -Onone -g -Xcc -isystem -Xcc /swift/usr/lib/swift/clang/include main.swift
developer@ubuntu:~/SORACOM/lldb-failure-demo-swift-4.1-beta/Sources/lldb-failure-demo$ lldb main
(lldb) target create "main"
Current executable set to 'main' (x86_64).
(lldb) b main.swift:5
Breakpoint 1: where = main`main + 71 at main.swift:5, address = 0x0000000000000f57
(lldb) run
Process 4912 launched: '/home/developer/SORACOM/lldb-failure-demo-swift-4.1-beta/Sources/lldb-failure-demo/main' (x86_64)
Process 4912 stopped
* thread #​1, name = 'main', stop reason = breakpoint 1.1
frame #​0: 0x0000555555554f57 main`main at main.swift:5
2
3 let output = "This is some text output."
4
-> 5 print("1. " + output)
6
7 print("2. " + output)
8
Target 0: (main) stopped.
(lldb) po output
"This is some text output."
(lldb) continue
Process 4912 resuming
1. This is some text output.
2. This is some text output.
This is the end of the program.
Process 4912 exited with status = 0 (0x00000000)
(lldb) exit
developer@ubuntu:~/SORACOM/lldb-failure-demo-swift-4.1-beta/Sources/lldb-failure-demo$ Doesn't work with "swift build": developer@ubuntu:~/SORACOM/lldb-failure-demo-swift-4.1-beta$ swift build -Xcc -isystem -Xcc /swift/usr/lib/swift/clang/include
Compile Swift Module 'lldb_failure_demo' (1 sources)
Linking ./.build/x86_64-unknown-linux/debug/lldb-failure-demo
developer@ubuntu:~/SORACOM/lldb-failure-demo-swift-4.1-beta$ lldb .build/debug/lldb-failure-demo
(lldb) target create ".build/debug/lldb-failure-demo"
Current executable set to '.build/debug/lldb-failure-demo' (x86_64).
(lldb) b main.swift:5
Breakpoint 1: where = lldb-failure-demo`main + 71 at main.swift:5, address = 0x0000000000000f57
(lldb) run
Process 5015 launched: '/home/developer/SORACOM/lldb-failure-demo-swift-4.1-beta/.build/debug/lldb-failure-demo' (x86_64)
Process 5015 stopped
* thread #​1, name = 'lldb-failure-de', stop reason = breakpoint 1.1
frame #​0: 0x0000555555554f57 lldb-failure-demo`main at main.swift:5
2
3 let output = "This is some text output."
4
-> 5 print("1. " + output)
6
7 print("2. " + output)
8
Target 0: (lldb-failure-demo) stopped.
(lldb) po output
error: in auto-import:
failed to get module 'lldb_failure_demo' from AST context:
/swift-DEVELOPMENT-SNAPSHOT-2018-02-08-a-ubuntu16.04/usr/lib/swift/CoreFoundation/CoreFoundation.h:25:10: note: while building module 'SwiftGlibc' imported from /swift-DEVELOPMENT-SNAPSHOT-2018-02-08-a-ubuntu16.04/usr/lib/swift/CoreFoundation/CoreFoundation.h:25:
#include <sys/types.h>
^
<module-includes>:3:9: note: in file included from <module-includes>:3:
#import "///usr/include/utmp.h"
^
# LOTS OF SIMILAR OUTPUT OMITTED...
error: could not build C module 'CoreFoundation'
(lldb) ^C
(lldb) ^D
developer@ubuntu:~/SORACOM/lldb-failure-demo-swift-4.1-beta$ |
The "real" fix for this is going to be a change in the install location of the clang resource directory, see my WIP here: https://github.com/adrian-prantl/swift-lldb/commits/37354542 Can you confirm that this patch fixes the issue for you? |
This should be fixed on master and swift-4.1-branch now. |
Comment by Mason Mark (JIRA) Thank you @adrian-prantl! I verified that the issue is indeed fixed as of the 2018-02-22 developer snapshot, as the transcript below shows. However, I just filed a separate bug, SR-7065, because the REPL stopped working on Linux in this snapshot, and it fails in a very similar way as lldb was failing before this fix. The similarity of the errors and the timing made me think the issue might be related to this fix — maybe there's something that now needs to be done for the REPL. Anyway, I could be wrong, and it might be outside the scope of your work, but I'm pinging you anyway since if SR-7065 is in fact related to the fix for this SR-6954, you might have a better idea who to talk to and perhaps what clue to give them. Cheers! developer@ubuntu:~/lldb-failure-demo-swift-4.1-beta$ lldb .build/debug/lldb-failure-demo
(lldb) target create ".build/debug/lldb-failure-demo"
Current executable set to '.build/debug/lldb-failure-demo' (x86_64).
(lldb) b main.swift:5
Breakpoint 1: where = lldb-failure-demo`main + 80 at main.swift:5, address = 0x0000000000000e90
(lldb) run
Process 12842 launched: '/home/developer/lldb-failure-demo-swift-4.1-beta/.build/debug/lldb-failure-demo' (x86_64)
Process 12842 stopped
* thread #​1, name = 'lldb-failure-de', stop reason = breakpoint 1.1
frame #​0: 0x0000555555554e90 lldb-failure-demo`main at main.swift:5
2
3 let output = "This is some text output."
4
-> 5 print("1. " + output)
6
7 print("2. " + output)
8
Target 0: (lldb-failure-demo) stopped.
(lldb) po output
"This is some text output."
(lldb) ^C
(lldb) ^D
developer@ubuntu:~/lldb-failure-demo-swift-4.1-beta$
developer@ubuntu:~/lldb-failure-demo-swift-4.1-beta$
developer@ubuntu:~/lldb-failure-demo-swift-4.1-beta$ echo WOO HOO IT WORKS
WOO HOO IT WORKS
developer@ubuntu:~/lldb-failure-demo-swift-4.1-beta$ |
Comment by Mason Mark (JIRA) This issue has recurred in the Swift 4.1 release. However, the workaround of moving |
Comment by Mason Mark (JIRA) @adrian-prantl @belkadan I think this issue should be re-opened and SR-7065 should be closed, so that the JIRA issue state matches the actual experience of Linux users who might be searching for a solution here. Namely, after installing Swift 4.1 final on Linux, the REPL does work (so SR-7065 is resolved), but lldb does not work for debugging a program that imports Foundation (so this issue SR-6954 is not resolved) However, I am not sure how all that "Swift Sync System" stuff works with mapping these issues to your internal Radar thing, so I will leave closing/re-opening these JIRA tickets to you guys. My understanding is that the fix for SR-6954 (this issue) and the fix for SR-7065 were mutually exclusive, and the REPL "won". The workaround identified (moving the /usr/lib/lldb/clang/include directory) is now in the comments thread for both issues. |
mason (JIRA User): The workaround you are mentioning is part of the current master branch. Can you confirm that this works as expected using the latest snapshot (Ubuntu 16.04)? |
To clarify: I'm referring to the development snapshot, not to the swift-4.1 snapshot. |
Comment by Mason Mark (JIRA) @adrian-prantl I tried it with the snapshot you referenced. It looks like it works, but I couldn't 100% confirm that because lldb still fails, with what seems like could be an unrelated issue (transcript below, the problem is "could not build C module '_SwiftDispatchOverlayShims'"). developer@ubuntu:~$ swift --version
Swift version 4.2-dev (LLVM 95345677bd, Clang daefc772c1, Swift 76c264e9a1)
Target: x86_64-unknown-linux-gnu
developer@ubuntu:~$
developer@ubuntu:~$ swift
Welcome to Swift version 4.2-dev (LLVM 95345677bd, Clang daefc772c1, Swift 76c264e9a1). Type :help for assistance.
1> import Foundation
2> let foo = FileManager.default
foo: Foundation.FileManager = {
Foundation.NSObject = {}
}
3> ^C
3> ^D
developer@ubuntu:~$
developer@ubuntu:~$
developer@ubuntu:~$
developer@ubuntu:~$ cd lldb-failure-demo-swift-4.1-beta/
developer@ubuntu:~/lldb-failure-demo-swift-4.1-beta$
developer@ubuntu:~/lldb-failure-demo-swift-4.1-beta$ swift build
developer@ubuntu:~/lldb-failure-demo-swift-4.1-beta$
developer@ubuntu:~/lldb-failure-demo-swift-4.1-beta$
developer@ubuntu:~/lldb-failure-demo-swift-4.1-beta$ lldb .build/debug/lldb-failure-demo
(lldb) target create ".build/debug/lldb-failure-demo"
Current executable set to '.build/debug/lldb-failure-demo' (x86_64).
(lldb) b main.swift:5
Breakpoint 1: where = lldb-failure-demo`main + 71 at main.swift:5, address = 0x0000000000000e97
(lldb) run
Process 23403 launched: '/home/developer/lldb-failure-demo-swift-4.1-beta/.build/debug/lldb-failure-demo' (x86_64)
Process 23403 stopped
* thread #​1, name = 'lldb-failure-de', stop reason = breakpoint 1.1
frame #​0: 0x0000555555554e97 lldb-failure-demo`main at main.swift:5
2
3 let output = "This is some text output."
4
-> 5 print("1. " + output)
6
7 print("2. " + output)
8
Target 0: (lldb-failure-demo) stopped.
(lldb) po output
error: in auto-import:
failed to get module 'lldb_failure_demo' from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "DispatchOverlayShims.h"
^
error: /swift-DEVELOPMENT-SNAPSHOT-2018-03-28-a-ubuntu16.04/usr/lib/swift/shims/DispatchOverlayShims.h:204:20: error: implicit conversion of C pointer type 'dispatch_data_t _Nonnull' (aka 'struct dispatch_data_s *') to Objective-C pointer type '__swift_shims_dispatch_data_t _Nonnull' (aka 'id') requires a bridged cast
return applier(data, off, loc, size);
^
/swift-DEVELOPMENT-SNAPSHOT-2018-03-28-a-ubuntu16.04/usr/lib/swift/shims/DispatchOverlayShims.h:204:20: note: use __bridge to convert directly (no change in ownership)
return applier(data, off, loc, size);
^
/swift-DEVELOPMENT-SNAPSHOT-2018-03-28-a-ubuntu16.04/usr/lib/swift/shims/DispatchOverlayShims.h:204:20: note: use __bridge_transfer to transfer ownership of a +1 'dispatch_data_t _Nonnull' (aka 'struct dispatch_data_s *') into ARC
return applier(data, off, loc, size);
^
error: could not build C module '_SwiftDispatchOverlayShims'
(lldb) ^C
(lldb) ^D
developer@ubuntu:~/lldb-failure-demo-swift-4.1-beta$
developer@ubuntu:~/lldb-failure-demo-swift-4.1-beta$
developer@ubuntu:~/lldb-failure-demo-swift-4.1-beta$
developer@ubuntu:~/lldb-failure-demo-swift-4.1-beta$ env
XDG_SESSION_ID=78
TERM=xterm-256color
SHELL=/bin/bash
DERBY_HOME=/usr/lib/jvm/java-8-oracle/db
SSH_CLIENT=172.16.142.1 57433 22
SSH_TTY=/dev/pts/0
LC_ALL=en_US.UTF-8
USER=developer
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
MAIL=/var/mail/developer
PATH=/home/developer/bin:/home/developer/.local/bin:/swift/usr/bin:/swift/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin
PWD=/home/developer/lldb-failure-demo-swift-4.1-beta
JAVA_HOME=/usr/lib/jvm/java-8-oracle
LANG=en_US.UTF-8
SHLVL=1
HOME=/home/developer
LANGUAGE=en_US:
LOGNAME=developer
J2SDKDIR=/usr/lib/jvm/java-8-oracle
SSH_CONNECTION=172.16.142.1 57433 172.16.142.128 22
LC_CTYPE=UTF-8
LESSOPEN=| /usr/bin/lesspipe %s
XDG_RUNTIME_DIR=/run/user/1001
J2REDIR=/usr/lib/jvm/java-8-oracle/jre
LESSCLOSE=/usr/bin/lesspipe %s %s
_=/usr/bin/env
OLDPWD=/home/developer
developer@ubuntu:~/lldb-failure-demo-swift-4.1-beta$ |
I cherry-picked all the related bugfixes to the swift-4.1 branch now, too. Could you try this again with the lates swift-4.1 snapshot? |
Attachment: Download
Environment
swift-4.1-DEVELOPMENT-SNAPSHOT-2018-02-07
(and several previous snapshots, such as theswift-4.1-DEVELOPMENT-SNAPSHOT-2018-02-01
shown above)Ubuntu Server 16.4.3
(swift's documented prerequsites installed)
Additional Detail from JIRA
md5: 1713c91d079fe982fe6d446d4a60497f
relates to:
Issue Description:
Interactive debugging using
lldb
works on Linux with Swift 4.0.x, but not Swift 4.1 (the2018-02-07
dev snapshot, or any other 4.1 snapshot I've tried).I am not sure what the underlying cause is, but I have created a minimal SPM package that demonstrates the issue (attached). It is a Swift package containing a very simple program that just imports
Foundation
and prints some text:In Swift 4.0.2 and 4.0.3, you can use
lldb
to run this program, set a breakpoint, and inspect variables:However, under Swift 4.1,
lldb
blows up and fails when you try this:If the
import Foundation
line is removed, thenlldb
is able to debug this program on Linux under Swift 4.1.I note that this actually does not work out of the box on Swift 4.0.x, either;
lldb
debugging only works after setting the environment variables below (taken from this comment by MatiMax (JIRA User)):So, perhaps this is just a straightforward regression from 4.0.x.
However, I noticed that the errors emitted by
lldb
above do look very similar to the errors you will see on Swift 4.0.x if you neglect to set those two variables. So it may be that there is some similar — but additional — environmental setup step required to makelldb
work on Linux with Swift 4.0.1. (I myself don't know enough about software packaging on Linux to venture a guess.)The attached demo project should hopefully be enough to easily reproduce the issue, either way.
The text was updated successfully, but these errors were encountered: