首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >远程LLDB调试-码头容器

远程LLDB调试-码头容器
EN

Stack Overflow用户
提问于 2017-08-06 14:32:33
回答 2查看 1.9K关注 0票数 1

我正在尝试用LLDB4.0.1设置远程调试。有一个带有Arch的码头(17.06.0-ce)容器。Docker容器是在特权模式中设置的,因此现在可以在容器中启动LLDB。容器包含core_service,这是锈蚀可执行文件。

在容器(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-server platform --server --listen 0.0.0.0:1234在容器内启动lldb-server .我可以从主机lldb连接到容器lldb-服务器,但不能附加/创建进程。

在主机上运行的命令(lldb-server在容器=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

我怎么才能修好它?是否有任何端口、arch linux设置会导致此错误?

似乎,在docker容器中的lldb服务器权限存在一些问题。

命令运行在主机(容器中的lldb-服务器) (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上,但我不知道它是什么。在容器中以root形式运行lldb -服务器,我可以使用lldb执行shell命令。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-03-05 13:48:49

需要平台端口(在您的情况下是1234)和gdbserver端口(默认情况下随机生成)。可以通过lldb-server选项--gdbserver-port.强制执行gdbserver端口。

在Fedora 29 x86_64上测试:

代码语言:javascript
复制
docker run --privileged -p 5000:5000 -p 5001:5001 fedora bash -c 'dnf -y install lldb;lldb-server platform --server --listen 0.0.0.0:5000 --gdbserver-port 5001'

代码语言:javascript
复制
echo 'int main(){}' >main.c;gcc -g -o main main.c;lldb -o 'platform select remote-linux' -o 'platform connect connect://localhost:5000' -o "target create ./main" -o 'b main' -o 'process launch'

(lldb) process launch
Process 45 stopped
* thread #1, name = 'main', stop reason = breakpoint 1.1
    frame #0: 0x000000000040110f main`main at main.c:1
-> 1    int main(){}

Process 45 launched: '/root/main' (x86_64)
(lldb) _
票数 2
EN

Stack Overflow用户

发布于 2017-08-06 19:07:26

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

代码语言:javascript
复制
docker run --pid=host --privileged <yourimage>

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45533026

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档