Skip to content
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

Not able to debug with "gdb -i=mi" in docker #6168

Closed
lauccode opened this issue Mar 1, 2022 · 1 comment
Closed

Not able to debug with "gdb -i=mi" in docker #6168

lauccode opened this issue Mar 1, 2022 · 1 comment
Labels
is:bug Something isn't working as intended needs-triage Issue hasn't been assessed yet

Comments

@lauccode
Copy link

lauccode commented Mar 1, 2022

What did you expect to happen?

I'm launching gdb in emacs with this command after <Alt+x>, gdb :

gdb -i=mi /docker:reverent_black:/mnt/build/logicalError -ex "set substitute-path /home/name_on_manjaro/CPP-Debug-Docker/ /mnt/"

I was expecting no issue because of "set substitute-path".

What actually happened?

I'm trying to use gdb on code in a docker but it is not working well.
I can debug with gud-gdb(console on left and code on right) but not with gdb "gdb -i=mi" (with all information in 6 windows).

I tried it on manjaro (and also ubuntu) with different projet.
To be sure, I tested with this simple projet to reproduce with "hello world" and a docker and I have the same result :
https://github.com/leimao/CPP-Debug-Docker.

The issue is that I can only follow the code progress in gdb console but not directly on the code file with the arrow.
No issue if not in docker.

Describe your attempts to resolve the issue

I guess something is missing in my gdb command for the docker but I don't see what.

If someone already debug with gdb in a docker maybe he can help.

I don't see on internet if this is a known limitation of gdb used in docker with emacs

Steps to reproduce

I tried it on manjaro (and also ubuntu) with diferent projet.
To be sure, I tested with this simple projet to reproduce with "hello world" and a docker and I have the same result :
https://github.com/leimao/CPP-Debug-Docker.

System Information

https://pastebin.com/V21kWuLS

@lauccode lauccode added is:bug Something isn't working as intended needs-triage Issue hasn't been assessed yet labels Mar 1, 2022
@lauccode
Copy link
Author

more information

if I build outside the docker, the gdb command in emacs is :

gdb -i=mi /docker:name_of_docker_container:/mnt/build/logicalError -ex "set substitute-path /home/name_on_manjaro/CPP-Debug-Docker/ /mnt/"

if I build inside the docker, the gdb command in emacs is (here the paths are already good) :

gdb -i=mi /docker:name_of_docker_container:/mnt/build/logicalError

To use docker :

to launch the docker daemon
sudo dockerd
to be able to pass following command in another terminal
sudo chmod 666 /var/run/docker.sock
to build and run the docker
cd CPP-Debug-Docker
docker build -f cpp.Dockerfile -t cpp-debug:0.0.1 .\n
docker run -it --rm --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v $(pwd):/mnt cpp-debug:0.0.1
to know your container name to pass in gdb command in another terminal
docker container ls

Strange issue :

<Alt+x> gud-gdb is launched with the same command that gdb but with "--fullname" option rather than "-i=mi" at the start.
gdb --fullname /docker:name_of_docker_container:/mnt/build/logicalError -ex "set substitute-path /home/name_on_manjaro/CPP-Debug-Docker/ /mnt/"

If I launch <Alt+x> gdb, there is no code following with the arrow. But We can see the breakpoint.
If I launch <Alt+x> gud-gdb, there is code following with the arrow. But We can not see the breakpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is:bug Something isn't working as intended needs-triage Issue hasn't been assessed yet
Projects
None yet
Development

No branches or pull requests

1 participant