To set up a native debug session using GDB, it is only necessary to run the GDB debugger on the target.
Note: To support symbolic debugging the application must have been compiled with the -g option passed to gcc. This adds DWARF debugging information to the executable.
The GDB debugger on the target must be passed the name of the application to be debugged, so that it can access the debug information contained within the binary:
target# gdb /root/hello GNU gdb 6.3 Copyright 2004 Free Software Foundation, Inc. <snip> This GDB was configured as "sh4-linux"... (gdb)
The application can be run to main like this:
(gdb) break main Breakpoint 1 at 0x400656: file main.c, line 20. (gdb) run Starting program: /root/hello Breakpoint 1, main() at main.c:20 20 printf("Welcome to the application\n"); (gdb)
The application can be debugged in exactly the same way as it would be on a host machine. As before, refer to the built-in help and online documentation for more information.