Debug cross-compiled executable on Raspberry Pi from Eclipse

If you were able to launch a cross compiled executable on the target machine (Raspberry Pi) as described in my former post, then you probably would like to debug it remotely as well.

Update crosstool-ng
I have already described how to setup crosstool-ng for cross-compiling purposes, but in order to enable cross-debug support a few other steps needs to be done. First of all you need to install some additional packages from Fedora repository.

su - #change to root
#Install dependencies for crostool-ng debug support
yum install expat expat-devel python python-devel

If these packages are not installed then probably you will get the following error message during the build of crosstool-ng tools.

[INFO ]  Installing cross-gdb
[ERROR]    configure: error: expat is missing or unusable
[ERROR]    make[2]: *** [configure-gdb] Error 1

After the dependencies are successfully installed just need to follow the same steps what are described in the Configure the toolchain chapter and additional to those steps select the required debug options in the menuconfig of ct-ng.

  • Debug facilities
    • Enable “ltrace”
    • Enable “gdb”
    • Enable “duma”
    • Enable “dmalloc”
    • Keep “strace” on disable since it does not seem to build with crosstool-ng 1.16.0

Save the changes, exit from the menuconfig and build the crosstool-ng tools as usual…

Debug Configuration in Eclipse
I suppose you have already setup Run Configuration in Eclipse and successfully executed your cross-compiled binary on the target machine as described here. If not then it is the right time to do it. After it is done, just open Debug Configuration for your project and select the Debugger tab.

GDB debugger

Fill the GDB debugger field with the browse button. The cross-debugger shall be available under your crostool-ng tools:

/opt/crosstool-ng-1.16.0-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gdb

Click on the Debug button and Eclipse is going to copy your cross-compiled binaries to remote machine and start to debug it remotely.

Eclipse Remote Debug

Leave a comment