Steps:
One. Familiar with the basic way of debugging with GDB on common computer. See also: http://www.ibm.com/developerworks/linux/library/l-gdb/
Two. Download "GdB Quick Reference", 2 pieces of paper, printed out and put at hand for standby.
Three. Allow embedded systems to support Gdbserver. (on OpenWrt, that is, select Compile gdbserver when make Menuconfig)
Four. For debugging
For the 4th, the following is based on the MIPS CPU OPENWRT platform for example
Computer IP address is 192.168.1.115, the device IP address is 192.168.1.1, IP communication with each other
Compile the tool by compiling the following code into an executable file on the device that supports GDB Test.bin
#include <stdio.h>
int main (int argc, char *argv[])
{
int i=0; I=1;
printf ("%d", i++);
i++;
printf ("%d,%d", j + +, i++);
}
Compile commands for example:
$ (openwrt_dir)/staging_dir/toolchain-mips_gcc4.1.2/bin/mips-linux-uclibc-gcc-g-wall-i. I $ (PWD)/.. /.. /include/-I $ (openwrt_dir)/build_dir/linux-msp71xx/linux-2.6.20.21/-o test.bin test.c
Copy the compiled test.bin to the Linux/usr/directory running on the embedded device
Start the gdbserver on the device by executing the following statement
Gdbserver Host:2345/usr/test.bin
Execute the following command on your computer:
/openwrt/staging_dir/toolchain-mips_gcc4.1.2/bin/mips-linux-uclibc-gdb Test.bin
Enter the GDB interface on your computer, and execute the following command to add a breakpoint to the main function:
Break Main
The GDB interface on the computer executes the following command, established on the device by the Gdbserver connection:
Target Remote 192.168.1.1:2345
On the computer, the GDB interface executes the following command to start running the program:
Continue at this point into the debugging, use see the previous mentioned <gdb quick reference>
Execute the following command to terminate GDB debugging:
Quit