Debugging embedded Linux devices using GDB __linux

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.