I am fighting with Eclipse (in Windows) to make it connect to my Linux box and compile and debug C++ code there remotely.
What I have working:
perl ./daemon.pl 4075
)Some manual things I can do (without Eclipse):
ssh mybox 'cd /path/to/project; gdb main'
ssh mybox 'cd /path/to/project; gdbserver fqdn:10000 main'
What is not working: Debug in Eclipse
Other things that might cause problems:
ssh
binary provided with MSYS/Git (not on PATH
)PATH
I really would like to do remote debugging in Eclipse for my C++ projects. Do you have any suggestions how to proceed from here?
Sanity check with CLI
Before you do anything, make sure you:
This answer supposes that you can do on the development board:
sudo apt-get install gdbserver
gdbserver :1234 path/to/executable
And on host:
aarch64-linux-gnu-gdb \
-ex "target remote board-hostname:1234" \
-ex "file path/to/cross/compiled/executable" \
-ex 'tb main' \
-ex c
and then step debug everything correctly.
Eclipse setup
Tested in Ubuntu 16.04 host, Eclipse Oxygen 4.7.0 (downloaded from website), gdbserver
7.12, aarch64-linux-gnu-gdb
7.6.
I have successfully used all of the following methods:
Manual
With this method, we have to launch gdbserver
on the target before running debug on Eclipse.
Pro: dispenses configuring SSH connections through Eclipse to allow Eclipse to
Con: you have to relaunch gdbserver
every time debugging starts. This could be overcome if Eclipse understood gdbserver --multi
, but I don't think it does?
Due to its simplicity, I recommend that you get this method working first.
Open the debug configurations, then create a new "C / C++ Remote Application".
Under the tab "Main":
select the "Name", "Project" and "C/C++ Application" as usual for a local debug
at the bottom launcher, click "Select other", check "Use configuration specific settings" and pick "GDB (DSF) Manual Remote Debugging Launcher"
Why we do this: the automatic launcher first connects to the board with SSH and launches the gdbserver
for you.
Under the tab "Debugger":
"GDB debugger": same as used from CLI on host, aarch64-linux-gnu-gdb
for this example
Sub-tab "Connection": set hostname and port as passed to the host on CLI (board-hostname
and 1234
)
Finally, manually launch gdbserver
on the target just as we did from the CLI:
gdbserver :1234 path/to/executable
and start the debugger from Eclipse normally.
You have to restart gdbserver
every time you terminate the program.
Automatic with password auth
This is the best method for development boards, which have fixed publicly known passwords.
It connects to the target with SSH and a password, and launches gdbserver
on the target automatically every time, which is super convenient!
Target gdbserver
stdout goes to the Eclipse "Console" window, which further reduces window switching.
In Eclipse set:
/root/path/to/project/path/to/executable
Automatic with public key
Very similar to the password authentication, except that you must go to: "Connection", "New", and choose "Public key based authentication"
Pros:
Cons:
SSH can connect without a password if you:
~/.ssh/authorized_keys
on the target to contain the ~/.ssh/id_rsa.pub
from the hostBefore using this method, make sure that your authorized keys work from the command line, i.e. you should now be able to do:
ssh user@host
without typing any password.
Change the current working directory of the process