Debug GDB + gdbserver

Source: Internet
Author: User

GDB + gdbserver is a common method for debugging the target board.
After reading some online materials and some of my own experiences, write a complete record:
My environment is as follows: Host 192.168.0.33 target: 192.168.0.34
NFS shared directory: Mount-T nfs-O nolock/home/itlanger/work/mnt

Compile arm-GDB:
Download the gdb source code:

$ CD downloads

$ Wget-T 0-W 30-C http://ftp.gnu.org/gnu/gdb/gdb-6.6.tar.gz
Tar zxvf gdb-6.6.tar.gz
CD gdb-6.6
./Configure -- target = arm-Linux -- prefix =/usr/local/ARM-GDB-V

Make
Sudo make install
Export Path = $ path:/usr/local/ARM-GDB
Compile arm-GDB-Server
Cd ~ /Downloads/gdb-6.6/GDB/gdbserver
./Configure -- target = arm-Linux -- Host = arm-Linux
Make cc =/usr/local/ARM/3.4.1/bin/ARM-Linux-GCC # Here is the path of the Cross Compiler
CP gdbserver ~ /Work ## gdbserver is compiled and generated
Export Path = $ path:/usr/local/ARM-GDB/bin (preferably added to. bashrc)

Copy the libthread Library (if this step is not done, an error will occur when running gdbserver !)
$ CD/usr/local/ARM/3.4.1/ARM-Linux/lib
$ LS-l libthread_db *
-Rwxr-XR-x 1 2619 man 29151 libthread_db-1.0.so
Lrwxrwxrwx 1 2619 man 17 2008-05-25 libthread_db.so-> libthread_db.so.1
Lrwxrwxrwx 1 2619 man 19 2008-05-25 libthread_db.so.1-> libthread_db-1.0.so

$ CP libthread_db-1.0.so ~ /Work

Under minicom:
# Cd/lib/
# Cp/mnt/libthread_db-1.0.so/lib/
# Ln-s libthread_db-1.0.so libthread_db.so.1
# Ln-s libthread_db-1.0.so libthread_db.so
Test
Write a program, compile it with arm-Linux-gcc-G, and put it under the Work directory (My name is third)

Under minicom:

CD/mnt

./Gdbserver 192.168.0.33: 6666 third
Process third created; pid = 356
Listening on port 6666
Terminal:
Export Path = $ path:/usr/local/ARM-GDB/bin
Cd ~ /Work
Arm-Linux-GDB third
Gnu gdb 6.6
Copyright (c) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
Welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "-- Host = i686-pc-linux-gnu -- target = arm-Linux "...
(GDB)

(GDB) target remote 192.168.0.34: 2345 ## (connection target)
Remotely debugging using 192.168.0.34: 2345
0x40000dd0 in ?? () From/lib/ld-linux.so.2
Now you can set breakpoints through L and B.
Run: run the command C #. Remember that run is not used here, because the program has been started by gdbserver on the target board. The output result is on the target board.

In this way, emacs can be used for remote debugging.
M-x gdba # (I have bound it to F10)

Run gdba (like this): Arm-Linux-GDB-annotate = 3 third

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.