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:
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:
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:
5) Specify the full path to the GDB server binary file uploaded earlier. Then click "Apply", "Debug":
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:
7) Allow perspective switch to Debug and make this setting permanent:
8) This is how cross-debugger looks like:
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; }