远程LLDBdebugging – Docker容器

我正在尝试使用LLDB 4.0.1进行远程debugging。 Arch linux有一个docker(17.06.0-ce)容器。 Docker容器被设置为特权模式 ,所以现在LLDB可以在容器中启动。 容器包含Rust可执行文件的core_service。

在container (lldb) target create target/debug/core_service Current executable set to 'target/debug/core_service' (x86_64). (lldb) process launch Process 182 launched: '/srv/core_service/target/debug/core_service' (x86_64)运行的命令(lldb) target create target/debug/core_service Current executable set to 'target/debug/core_service' (x86_64). (lldb) process launch Process 182 launched: '/srv/core_service/target/debug/core_service' (x86_64) (lldb) target create target/debug/core_service Current executable set to 'target/debug/core_service' (x86_64). (lldb) process launch Process 182 launched: '/srv/core_service/target/debug/core_service' (x86_64)

远程debugging存在问题,lldb-server在lldb-server platform --server --listen 0.0.0.0:1234容器内启动lldb-server platform --server --listen 0.0.0.0:1234 。 我可以从主机lldb连接到容器lldb-server,但是我无法附加/创build进程。

命令在主机上运行(lldb-server在container = localhost:1234) (lldb) platform select remote-linux Platform: remote-linux Connected: no (lldb) platform connect connect://localhost:1234 Platform: remote-linux Triple: x86_64-*-linux-gnu OS Version: 4.12.4 (4.12.4-1-ARCH) Kernel: #1 SMP PREEMPT Fri Jul 28 18:54:18 UTC 2017 Hostname: 099bd76c07c9 Connected: yes WorkingDir: /srv/core_service (lldb) target create target/debug/core_service Current executable set to 'target/debug/core_service' (x86_64). (lldb) process launch error: connect remote failed (Connection refused) error: process launch failed: Connection refused (lldb) platform select remote-linux Platform: remote-linux Connected: no (lldb) platform connect connect://localhost:1234 Platform: remote-linux Triple: x86_64-*-linux-gnu OS Version: 4.12.4 (4.12.4-1-ARCH) Kernel: #1 SMP PREEMPT Fri Jul 28 18:54:18 UTC 2017 Hostname: 099bd76c07c9 Connected: yes WorkingDir: /srv/core_service (lldb) target create target/debug/core_service Current executable set to 'target/debug/core_service' (x86_64). (lldb) process launch error: connect remote failed (Connection refused) error: process launch failed: Connection refused

我该如何解决? 有没有任何docker,拱Linux设置,会导致这个错误?

看来,像docker容器中的lldb-server权限有一些问题。

在主机上运行的命令(容器中的lldb-server) (lldb) platform shell ps -A PID TTY TIME CMD 1 ? 00:00:00 bash 9 ? 00:00:00 nginx 10 ? 00:00:00 nginx 11 ? 00:00:00 lldb-server 25 ? 00:00:00 core_service 59 ? 00:00:00 lldb-server 68 ? 00:00:00 ps (lldb) platform shell kill -9 25 (lldb) platform process launch target/debug/core_service error: connect remote failed (Connection refused) error: Connection refused (lldb) platform process launch anything error: connect remote failed (Connection refused) error: Connection refused (lldb) platform shell ps -A PID TTY TIME CMD 1 ? 00:00:00 bash 9 ? 00:00:00 nginx 10 ? 00:00:00 nginx 11 ? 00:00:00 lldb-server 25 ? 00:00:00 core_service 59 ? 00:00:00 lldb-server 68 ? 00:00:00 ps (lldb) platform shell kill -9 25 (lldb) platform process launch target/debug/core_service error: connect remote failed (Connection refused) error: Connection refused (lldb) platform process launch anything error: connect remote failed (Connection refused) error: Connection refused (lldb) platform shell ps -A PID TTY TIME CMD 1 ? 00:00:00 bash 9 ? 00:00:00 nginx 10 ? 00:00:00 nginx 11 ? 00:00:00 lldb-server 25 ? 00:00:00 core_service 59 ? 00:00:00 lldb-server 68 ? 00:00:00 ps (lldb) platform shell kill -9 25 (lldb) platform process launch target/debug/core_service error: connect remote failed (Connection refused) error: Connection refused (lldb) platform process launch anything error: connect remote failed (Connection refused) error: Connection refused但我不知道它是什么。 lldb-server在容器中以root身份运行,我可以使用lldb执行shell命令。

这可能是因为服务器在主机上看不到任何进程。 它仍然封装在自己的PID名称空间中。 启动LLDB服务器时,请使用主机pid名称空间

 docker run --pid=host --privileged <yourimage> 

希望这将允许您的容器看到所有的主机进程