4.3. Running Applications from GDB

You can run GDB, the GNU Debugger, on your host system to debug programs running remotely on a target board or system.

When starting GDB, give it the pathname to the program you want to debug as a command-line argument. For example, if you have built the factorial program as described in Section 4.1, “Building an Application”, enter:

> arm-uclinuxeabi-gdb factorial.gdb

For uClinux you must specify the ELF binary, not the FLT binary that you load onto your target.

While this section explains the alternatives for using GDB to run and debug application programs, explaining the use of the GDB command-line interface is beyond the scope of this document. Please refer to the GDB manual for further instructions.

4.3.1. Connecting to the Sourcery G++ Debug Sprite

The Sourcery G++ Debug Sprite is a program that runs on the host system to support hardware debugging devices. You can use the Debug Sprite to run and debug programs on a target board without an operating system, or to debug an operating system kernel. See Chapter 5, “Sourcery G++ Debug Sprite” for detailed information about the supported devices.

You can start the Sprite directly from within GDB:

(gdb) target remote | arm-uclinuxeabi-sprite arguments

Refer to Section 5.2, “Invoking Sourcery G++ Debug Sprite” for a full description of the Sprite arguments.

4.3.2. Connecting to an External GDB Server

Sourcery G++ Lite includes a program called gdbserver that can be used to debug a program running on a remote ARM uClinux target. Follow the instructions in Chapter 3, “Sourcery G++ Lite for ARM uClinux” to install and run gdbserver on your target system.

From within GDB, you can connect to a running gdbserver or other debugging stub that uses the GDB remote protocol using:

(gdb) target remote host:port

where host is the host name or IP address of the machine the stub is running on, and port is the port number it is listening on for TCP connections.