Setting Up Cross-Debugging In Eclipse

1) Create text file C:\rpi-eclipse\workspace\HelloRaspiWorld\.gdbinit with the following contents:

set sysroot C:\rpi-eclipse\rpi-cross-toolchain\arm-linux-gnueabihf

2) In Eclipse, open "Run" -> "Debug Configurations" in the main menu:

Setting up Eclipse for Rasperry Pi Development - Opening Debug Configurations

3) On the left side, click "C/C++ Remote Application", then "New" (flat button at the top), then on click "HelloRaspiWorld Debug". Set up "Remote Absolute File Path for C/C++ Application" and "Commands to execute before application" as shown below:

Setting up Eclipse for Rasperry Pi Development - Setting Up Debug Configurations

4) On the "Debugger" tab, set up GDB Debugger name as "C:\rpi-eclipse\rpi-cross-toolchain\arm-linux-gnueabihf\bin\arm-linux-gnueabihf-gdb.exe" and go to "GDBServer settings" subtab:

Setting up Eclipse for Rasperry Pi Development - Setting Up Local Debugger

5) Specify the full path to the GDB server binary file uploaded earlier. Then click "Apply", "Debug":

Setting up Eclipse for Rasperry Pi Development - Setting Up Remote Debugger

6) Enter password for SSH access (default password for pi user is raspberry and allow Eclipse to add ssh key to the list of known ones:

Setting up Eclipse for Rasperry Pi Development - Entering Password for Remote Access

7) Allow perspective switch to Debug and make this setting permanent:

Setting up Eclipse for Rasperry Pi Development - Confirming Perspective Switch to Debug

8) This is how cross-debugger looks like:

Setting up Eclipse for Rasperry Pi Development - Cross-Debugger

9) Try this program to see how variable inspection works in cross-environment:

#include <iostream>

long long  fib( int  n )
{
    if( n <= 1 )
        return  1;
    else
        return  fib( n - 1 ) + fib( n - 2 );
}

int  main( int  argc, const char* const*  argv )
{
    std::cout << "First twenty Fibonacci numbers:\n" << std::endl;
    for( int  i = 0; i < 20; ++i )
        std::cout << "#" << i << ": " << fib(i) << std::endl;
    return  0;
}
Setting up Eclipse for Rasperry Pi Development - Variable Inspection in Cross-Debugger