Run and debug remotely

Before you can run and debug your application remotely, you have to make the files available to the target device. The best way to do that is via an NFS mount. Therefore export your workspace in the NFS configuration /etc/exports. It could look like this:

/home/taskit/workspace *(ro)

Now reload the exports, e.g.:

/etc/init.d/nfs-kernel-server reload

After that, you can mount the workspace on your device by entering the following command on the serial console:

mount host:/home/taskit/workspace /mnt -o nolock,tcp

Replace host (your workstation) and the path according to your setup. This step has to be repeated every time you reboot the target.

Now that your device can access the files, it is time to create the run and debug configurations. To do that, activate menu Run -> Run Configurations. There, double-click "C/C++ Remote Application" and you should get the following dialog:

Eclipse - Default run configurationEclipse - Default run configuration

In this dialog choose the remote connection you have previously configured, enter the absolute path of the binary on the target device and enable the checkbox "Skip download to target path.". If you configured an SSH connection with SFTP, you can also browse the target to enter the path. See the next screenshot for reference:

Eclipse - Adjusted run configurationEclipse - Adjusted run configuration

While you are at it, you can also set the correct gdb used for debugging. Here, the gdb from the Ångström toolchain is used:
Eclipse - GDB settingsEclipse - GDB settings
If you have an older product where the arm-linux-3.4.2- toolchain is used, you might get problems when using its debugger with Eclipse. But you can here also use the gdb from the Ångström toolchain or any other newer arm-gdb. You can find one on a new enough Starterkit-CD in the directory for the Stamp9G20/PortuxG20 or you can use this toolchain:

The setup is now finished and you can click on "Run". This starts the application on the target should result in the following output:
Eclipse - Remote RunEclipse - Remote Run

A debug configuration was automatically created. You can run it by clicking the arrow right of the bug toolbar icon and choose it from the items. The debugger is now started and your are asked to switch to the debug perspective - answer yes. It should now look like this:

Eclipse - Remote DebugEclipse - Remote Debug

You can now debug (single step, inspect variables, ...) as if it was a local application.

It might be, that while starting the debugger, the following warning pass by in the console window:

.gdbinit: No such file or directory.
[New Thread 1285]
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
warning: .dynamic section for "/usr/lib/" is not at the expected address (wrong library or version mismatch?)
warning: .dynamic section for "/lib/" is not at the expected address (wrong library or version mismatch?)
warning: .dynamic section for "/lib/" is not at the expected address (wrong library or version mismatch?)
warning: .dynamic section for "/lib/" is not at the expected address (wrong library or version mismatch?)
Error while mapping shared library sections:
/lib/ No such file or directory.

The first line is not really a problem but will vanish as a side effect of the change to remove the other warnings. Create a file called ".gdbinit" in the root directory of your project. In this file you can enter gdb commands that are executed before the debug is started. We need to set the sysroot to get rid of the warnings above. This is done by adding the following line to this file:

set sysroot /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/

Adjust the path if you use another toolchain.