Remote debugging

From Klaus' wiki
Jump to: navigation, search

Debugging on a tiny target system may be impossible, because there are no room for the gdb and all the source and binary files on the target system. Luckily remote debugging is available.

There are two (at least) options: DDD or Eclipse.

DDD is a gui for gdb, the GNU debugger. DDD might be available in Cygwin, I don't know. But it is available in all decent Linux distributions.

There are some prerequisites:

  • There shall be opened a port for connecting on the target, if a firewall is installed on the target
  • The source shall be available on the debugging host
  • The gdbserver shall be included on the target system (use make menuconfig)

When the code has been compiled and transferred to the target host start the remote gdbserver on the target:


]$ gdbserver <host-to-expect-connection-from>:<port-number> <program>


]$ gdbserver myprogram

Remember to look up options on the man page!

On the devhost

Fire up your debugging environment, i.e. DDD or Eclipse.


Now on the debugging host start DDD. In the command window below type in:

target extended-remote <target-host>:<port-number> <programme>


(gdb) target myprogram

In the console where you've started the gdbserver you should now see that a remote debugger has connected.

Remote debugging from host

Next open the executable in the DDD using the file command:

file <path-to-executable>/<executable>


file myprogram

The source shall open in the upper window.

Set a breakpoint either by continuously right-click on the line you want the breakpoint or by typing

break <path-to-source>/<source-file>:<line-number>


break ../main.cpp:14

Now run the program using the small window with the Run, Interrupt, Step,... buttons or typing run in the lower window.

You can single step by clicking on the Step button or by typing step in the lower window.

Ddd debugging.png

Try the different possibilities - its almost like using the built-in debugger in Eclipse (which by the way is also gdb :-) ).


In order to setup Eclipse as a debug station follow these instructions:

First setup the debug configuration as shown.

Gdbserver debugging1.png

In the debugger tab choose gdbserver debugger.

Gdbserver debugging2.png

Finally set-up the communication in the Connection tab.

Gdbserver debugging3.png