You can run GDB, the GNU Debugger, on your host system to debug programs running remotely on a target board or system. You can also run and debug programs using the GDB simulator.
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-none-eabi-gdb factorial
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.
GDB includes a simulator that allows you to debug ARM EABI applications without target hardware. To start and connect to the simulator from within GDB, use this command:
(gdb) target sim
The Sourcery CodeBench 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 6, “Sourcery CodeBench Debug Sprite” for detailed information about the supported devices.
You can start the Sprite directly from within GDB:
(gdb) target remote | arm-none-eabi-sprite arguments
Refer to Section 6.3, “Invoking Sourcery CodeBench Debug Sprite” for a full description of the Sprite arguments.
From within GDB, you can connect to a running gdbserver
or other debugging stub that uses the GDB remote protocol using:
(gdb) target remotehost
: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.
Connecting to a bare-metal target or simulator from GDB does not cause your program to be loaded into target memory. You must do this explicitly from GDB after you connect:
(gdb) load
Alternatively, you can use third-party tools to load your application into flash memory before starting GDB.
To begin execution of your application, you should generally use the
continue
command:
(gdb) continue
However, you should use run
instead of
continue
to start your program if you used
target sim
to connect:
(gdb) run