Eclipse Che - Debugging C++ code
Hi,
In Che workspace (c++ stack), i created new c++ project (basic application with some cout statements). i could run the application successfully. In order to debug - as in https://www.eclipse.org/che/docs/ide/debug/index.html#gdb, configuration is done. But the debug windows does not show anything other than breakpoints, is this a known issue ? Any support would be helpful.
Environment: Linux Che : 5.7.0
@mvidhya86 currently, using gdb debugger required privileged mode for a workspace container.
In your che.env, uncomment the following line, set it to true and restart Che:
#CHE_DOCKER_PRIVILEGED=false
This is a Docker security limitation.
Hi, I modified che.env and restarted, on click of debug, i get "Can not connect to: localhost ".
Can you provide a screenshot?
I can't see the image, sorry.
@mvidhya86 attach screenshot to the issue on Github. Do not reply via email
Works on my side:

Make sure your workspace container runs in a privileged mode (run docker inspect against it). Also, make sure you compile your binary with -g
@eivantsov - In che.env - CHE_DOCKER_PRIVILEGED is set to true. After restarting the container, docker inspect --format='{{.HostConfig.Privileged}}' containerID => returns false
Also tried this one: docker run -it --privileged=true --rm -v /usr/local/codenvy/chedata:/data -v /var/run/docker.sock:/var/run/docker.sock eclipse/che start but of no luck
And inside Che - debug still gives - can not connect to localhost error
Do you run docker inspect against a workspace container?
Can you share screenshots with your gdb debugger setup?
Hi, I got the debugger working. But still have some questions here: docker run -it --rm -v /usr/local/codenvy/chedata:/data -v /var/run/docker.sock:/var/run/docker.sock eclipse/che start
and in /usr/local/codenvy/chedata/che.env => CHE_DOCKER_PRIVILEGED is set to true docker inspect dc2 |less => has CHE_DOCKER_PRIVILEGED set to true
After this, i created new workspace (c++ stack) docker ps listed new container as well and now, docker inspect e22 |less => has no variable by name - CHE_DOCKER_PRIVILEGED How do i ensure that workspace container is also in PRIVILEGED mode ? But it has privileged under hostconfig - which is set to true
With these steps, in c++ project => shows debugger with the local binary set and and Host as localhost
There should not be any env variables injected into a workspace. When CHE_DOCKER_PRIVILEGED is set to true workspace containers are run in a privileged mode, ie when Che triggers Docker, this parameter is passed to Docker API.
@eivantsov - Do we have any alternatives here, as running container in privileged mode will have security issues (as it is mentioned in blogs) and also it is not recommended for production/ci environments
@mvidhya86 I do not have any alternatives since Docker does not offer ones for running gdb and/or gdbserver in a container
@eivantsov - ok, could you confirm that debugging works fine with newer version of che 5.8.0. i did the same steps - workspace container shows Privileged as true.
Compilation with -g and in project with -Debug configuration as below: Name=remoteGDB, DebugLocalBinary checked, Host=localhost Port is blank and BinaryPath=${current.project.path}/a.out , click of Debug does not show up anything
The same steps are going fine with version 5.7.2
@mvidhya86 can you flush your browser's local storage? This is a know issue - https://github.com/eclipse/che/issues/4582
Thanks, it works fine now (after clearing browser's local storage)
@eivantsov - remote debugging with gdbserver also needs Privileged Mode ?
Because i see: gdbserver localhost:2020 sampleproj/a.out gdbserver: linux_ptrace_test_ret_to_nx: Cannot PTRACE_TRACEME: Operation not permitted gdbserver: linux_ptrace_test_ret_to_nx: status 256 is not WIFSTOPPED!
(Note: With privileged mode - remote debugging works fine )
@mvidhya86 yes, bpth gdb and gdbserver require privileged mode.
Closing the issue.