I am trying to remote debug server side swift from macOS.
lldb-server
run on Ubuntu 16.04 on Docker on macOS. I am using swift-4.1-RELEASE binaries.
root@031ab2443e1a:/var/vapor# lldb-server version
lldb version 5.0.0 (git@github.com:apple/swift-lldb.git revision 76dfa56ed35eaa392f7e51088c08f08f1150d142)
Swift-4.1 (revision f01501c324876fc07820dc28923d7088fb7af847)
clang revision cd84be6c4294f9ec302c20c63a601cbaeaa6a017
llvm revision cf364153438b3ac07a4a7d721159936e439ba2e7
I am also using swift-4.1-RELEASE snapshot on macOS.
[omochi@omochi-iMac-PC43 ~]$ export TOOLCHAINS=org.swift.4120180329a
[omochi@omochi-iMac-PC43 ~]$ lldb -version
lldb-360.0.0 (buildbot 2018-03-29)
Swift-4.1 (revision f01501c324876fc07820dc28923d7088fb7af847)
clang revision cd84be6c4294f9ec302c20c63a601cbaeaa6a017
llvm revision cf364153438b3ac07a4a7d721159936e439ba2e7
I could connect them.
In server.
root@031ab2443e1a:/var/vapor# lldb-server platform --listen "*:31166" --server
Connection established.
In mac.
[omochi@omochi-iMac-PC43 ~]$ lldb
(lldb) platform select remote-linux
Platform: remote-linux
Connected: no
(lldb) platform connect connect://127.0.0.1:31166
Platform: remote-linux
Triple: x86_64-*-linux-gnu
OS Version: 4.9.93 (4.9.93-linuxkit-aufs)
Kernel: #1 SMP Wed Jun 6 16:55:56 UTC 2018
Hostname: 031ab2443e1a
Connected: yes
WorkingDir: /var/vapor
(lldb) platform process list
6 matching processes were found on "remote-linux"
PID PARENT USER TRIPLE NAME
====== ====== ========== ======================== ============================
1 0 (null) x86_64-*-linux dash
291 1 x86_64-*-linux vapor
423 0 x86_64-*-linux bash
572 291 x86_64-*-linux Run
587 0 x86_64-*-linux bash
676 423 x86_64-*-linux lldb-server
But, attach fails.
(lldb) attach 572
error: attach failed: Failed to connect port
I tested lldb in ubuntu to connect lldb-server in itself. Then attach is succeeded. So I think lldb-server run correctly to attach process.
Why attach from macOS is failed? How to solve this.
I found answer. lldb-server and lldb use other ports to debug. it can be specified by --min-gdbserver-port
and --max-gdbserver-port
options of lldb-server
. And I expose these ports I specified via docker function. I finally success to connect.
Just to elaborate on omochimetaru answer, you can specify the ports used by LLDB-server as such:
lldb-server platform --listen "*:31166" --server --min-gdbserver-port 31200 --max-gdbserver-port 31300
And of course you need to expose those ports in your Dockerfile:
EXPOSE 31166
EXPOSE 31200-31300
And also when you run the container:
docker run --privileged --name vapor-server -p 8080:8080 -p 31166:31166 -p 31200-31300:31200-31300 vapor-image
Please note you need to run the docker as privileged ( --privileged option), otherwise attaching the debugger will fail with an Operation not Permitted error.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.