6.2. Debug Sprite Example

Start by compiling and linking a simple test program for your target board, following the instructions in Chapter 4, “Using Sourcery G++ from the Command Line”. Use the -g option to tell the compiler to generate debugging information.

For example, to build the factorial program to run on MIPSsim, use:

> mips-sde-elf-gcc -g -Tmipssim-hosted.ld  main.c -o factorial

Next start the debugger on your host system:

> mips-sde-elf-gdb factorial

To connect GDB to the MDI target, use a command similar to:

(gdb) target remote | mips-sde-elf-sprite mdi:/23/2 mipssim

Refer to Section 6.5, “MDI Devices” for additional set-up required to use the Sprite with MDI devices.

The Sprite prints some status messages as it connects to your debug device and target board. If the connection is successful, you should see output similar to:

mips-sde-elf-sprite:Target reset
0x00008936 in ?? ()
(gdb)

Next, use GDB to load your program onto the target board.

(gdb) load

At this point you can use GDB to control the execution of your program as required. For example:

(gdb) break main
(gdb) continue