Getting Started Guide
User mode debugging
Native debugging with GDB
|
|
Native debugging with GDB
To set up a native debug session using GDB, it is only necessary to run the GDB debugger on the target. In this case, the only function of the host system is to act as a file server (if the application was cross-compiled on the host) so the target debugger can locate the source files.
Note: To support symbolic debugging the application must have been compiled with the -g option passed to the GNU compiler. This puts DWARF debugging information to be included in the executable to support the debugger. See the GDB documentation for details.
The GDB debugger on the target must be passed the name of the program to be debugged, so that it can access the DWARF symbolic debug information contained within the program file:
target# -gdb /home/<user>/hello GNU gdb 6.3 Copyright 2004 Free Software Foundation, Inc. ...................................................................... This GDB was configured as "sh4-linux"... (gdb) |
|
|
Initially the debugger stops the program at its entry point in the C run-time code. The first step to perform is to advance to main():
(gdb) break main Breakpoint 1 at 0x400656: file main.c, line 20. (gdb) continue Continuing. Breakpoint 1, main() at main.c:20 20 printf("Welcome to the application\n"); (gdb) |
|
|
From here onwards the target can be debugged in the same way as a native program normally would be on a host machine. As before, it is not the purpose of this guide to provide a tutorial in debugging, instead the reader is referred to the extensive GDB documentation on the web for details.
|