3. Debugging the sample

The GNU debugger (GDB) is one of the most important debugging tools for Linux. The gdbserver itself is a small application that carries out commands from the gdb, which runs on the development system. You will find the gdbserver in the Linux Starterkit's root file system, in the /usr/bin directory.

Before debugging a program, you must compile it with the appropriate flags (-g or -ggdb for more information).

arm-angstrom-linux-gnueabi-gcc -g example1.c -o example1_debug

If you include in debugging information, the binary created is much larger. As long as you have the original version with the debugging information on the development system, however, you can simply copy the smaller, stripped-down version to the target system. You can strip down the debugger using the arm-angstrom-linux-gnueabi-strip tool.

For remote debugging, you can set up communication between the gdbserver on the taskit device and the gdb on the development system either over a serial null modem cable or over a TCP/IP connection. The connection via TCP/IP is described below. First you need to start the gdbserver on the taskit device, and then create the connection from the gdb on the development computer:

gdbserver host:port example1_debug

Host should be replaced with the host, where gdb will be started, but it is currently ignored by gdbserver. As port, choose any available port. All command line parameters for the program (if you later need some) must be given in this call. Then you can start the gdb on the other system and create the connection to your taskit device:

arm-angstrom-linux-gnueabi-gdb example1_debug
(GDB) target remote remote_ip:port

Replace remote_ip with the ip of the target board and port with the port given to gdbserver. Now you are ready to start debugging with the usual gdb commands.