1

I'm trying to set up a remote debugging with LLDB 4.0.1. There's a docker (17.06.0-ce) container with Arch linux. Docker container is set in privileged mode, so now LLDB can be started in container. Container contains core_service which is Rust executable.

Commands run inside 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)

Problem exists with remote debugging, lldb-server is started inside container with lldb-server platform --server --listen 0.0.0.0:1234. I can connect from host lldb to container lldb-server, but I can't attach/create processes.

Commands run on host (lldb-server in 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

How can I fix it? Are there any docker, arch linux settings that would cause this error?

It seems, like there's some problem with lldb-server permissions in docker container.

Commands run on host (lldb-server in container) (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 But I can't figure out what can it be. lldb-server is run as root in container, I can execute shell commands using lldb.

3
  • Try adding --cap-add=ALL also and see if that helps? I am not sure it would but just in case it does Commented Aug 6, 2017 at 15:39
  • @TarunLalwani I tried with --cap-add=ALL , but there's still the same problem.
    – Adiqq
    Commented Aug 6, 2017 at 15:52
  • See if my latest answer helps Commented Aug 6, 2017 at 19:07

2 Answers 2

2

There is needed both platform port (1234 in your case) and gdbserver port (randomly generated by default). You can enforce the gdbserver port by lldb-server option --gdbserver-port.

Tested on Fedora 29 x86_64:

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'

and

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) _
0

This may be because the server cannot see any process on the host. It is still wrapped in its own PID namespace. When you launch the LLDB server, use a host pid name space

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

Hopefully this will allow your container see all the host processes

1
  • I tried it, but both executable and lldb-server are run inside container, so it didn't helped. It's weird because if I use docker exec -it /bin/bash and run lldb, I can launch process without problems. Problem is only with lldb-server. Now I also set --pid=host and could see this process on my host, so I tried to connect to it from my host lldb, but it didn't work either, there was the same error.
    – Adiqq
    Commented Aug 6, 2017 at 20:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.