6.2. Debug Sprite Example
Prev | Chapter 6. Sourcery G++ Debug Sprite | Next

## 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.

To build the `factorial` program to run on the ARMulator simulator, which can communicate with the Sprite via the RDI protocol, use:

    > arm-none-eabi-gcc -g -Tarmulator-ram-hosted.ld main.c \
        -o factorial

Next start the debugger on your host system:

    > arm-none-eabi-gdb factorial

The command for connecting GDB to the board depends on the debug device you are using; this is described in more detail in Section 6.3, “Invoking Sourcery G++ Debug Sprite”. If you are connecting via RDI, you must specify the full path to the RDI library file and configuration file for that library. Use quotes to escape the Sprite argument syntax from the shell. For example, use a command like this to connect to the ARMulator:

    (gdb) target remote | arm-none-eabi-sprite \
      "rdi:///?rdi-library=library&rdi-config=config" armulator

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:

    arm-none-eabi-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

Prev | Up | Next
Chapter 6. Sourcery G++ Debug Sprite | Home | 6.3. Invoking Sourcery G++ Debug Sprite