`
isiqi
  • 浏览: 16029706 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

gdb gdbserver 的安装使用

阅读更多

GDB和gdbserver可以很方便的调试目标机应用程序,今天通过查阅相关资料我也实现了这项有非常意义的技术。我的环境如下,可参考,目前较新gdb版本支持的交叉编译器应该较多。

主机linux:F9

目标机:S3C2440

目标机内核:2.6.30

主机交叉编译器:EBAI4.3.2

arm-linux-gdb、gdbserver版本7.2 (下载地址ftp.gnu.org/gnu/gdb/

调试程序:随便了,只要编译通过没问题就行,记住编译中-g选项

步骤见网上一朋友的操作,如下:

下载 gdb-7.0.1.tar.bz2 http://ftp.gnu.org/gnu/gdb/
tar -xvjf gdb-7.0.tar.bz2 -C /home/samba/code_other/(自己指定的目录)
cd /home/samba/code_other/gdb-7.0.1/
查看 cat README :
3步操作:
1: ./configure
2: make
3: make install

因为要进行交叉编译。因此要配置相关的配置选项。具体的查看 ./configure --help
(当然要有具体的交叉编译环境。我这里的交叉编译环境为 arm-linux-)
先编译host端的client端。gdb客户端。
./configure
--target=arm-linux --prefix=/home/samba/gdb.bin
make
make install
在/home/samba/gdb.bin 运行命令 tree
.
|-- bin
| |-- arm-linux-gdb
| |-- arm-linux-gdbtui
| `-- arm-linux-run
|-- lib
| |-- libarm-linux-sim.a
| `-- libiberty.a
`-- share
|-- gdb
| `-- syscalls
| |-- amd64-linux.xml
| |-- gdb-syscalls.dtd
| |-- i386-linux.xml
| |-- ppc-linux.xml
| `-- ppc64-linux.xml
|-- info
| |-- annotate.info
| |-- bfd.info
| |-- configure.info
| |-- dir
| |-- gdb.info
| |-- gdb.info-1
| |-- gdb.info-2
| |-- gdb.info-3
| |-- gdb.info-4
| |-- gdb.info-5
| |-- gdbint.info
| |-- gdbint.info-1
| |-- gdbint.info-2
| |-- stabs.info
| `-- standards.info
|-- locale
| |-- da
| | `-- LC_MESSAGES
| | |-- bfd.mo
| | `-- opcodes.mo
| |-- de
| | `-- LC_MESSAGES
| | `-- opcodes.mo
| |-- es
| | `-- LC_MESSAGES
| | |-- bfd.mo
| | `-- opcodes.mo
| |-- fi
| | `-- LC_MESSAGES
| | |-- bfd.mo
| | `-- opcodes.mo
| |-- fr
| | `-- LC_MESSAGES
| | |-- bfd.mo
| | `-- opcodes.mo
| |-- ga
| | `-- LC_MESSAGES
| | `-- opcodes.mo
| |-- id
| | `-- LC_MESSAGES
| | |-- bfd.mo
| | `-- opcodes.mo
| |-- ja
| | `-- LC_MESSAGES
| | `-- bfd.mo
| |-- nl
| | `-- LC_MESSAGES
| | `-- opcodes.mo
| |-- pt_BR
| | `-- LC_MESSAGES
| | `-- opcodes.mo
| |-- ro
| | `-- LC_MESSAGES
| | |-- bfd.mo
| | `-- opcodes.mo
| |-- ru
| | `-- LC_MESSAGES
| | `-- bfd.mo
| |-- rw
| | `-- LC_MESSAGES
| | `-- bfd.mo
| |-- sv
| | `-- LC_MESSAGES
| | |-- bfd.mo
| | `-- opcodes.mo
| |-- tr
| | `-- LC_MESSAGES
| | |-- bfd.mo
| | `-- opcodes.mo
| |-- vi
| | `-- LC_MESSAGES
| | |-- bfd.mo
| | `-- opcodes.mo
| `-- zh_CN
| `-- LC_MESSAGES
| |-- bfd.mo
| `-- opcodes.mo
`-- man
`-- man1
|-- arm-linux-gdb.1
|-- arm-linux-gdbtui.1
`-- arm-linux-run.1
然后把这个路径加入到PATH中。/etc/profile 中
在最后 export PATH=$PATH:/home/samba/gdb.bin
注:修改文件后要想马上生效还要运行
# source /etc/profile 不然只能在下次重进此用户时生效。
可以指定
--prefix=/usr/local/bin 省略编辑 /etc/profile 这一步了
运行如下:
# arm-linux-gdb
GNU gdb (GDB) 7.0.1
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-linux".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
客户端可以了。

server 端 cd ./gdb/gdbserver 查看README 后只要设置
./configure --target=arm-linux --host=arm-linux
因为gdbserver在目标板子上运行。
make
生成 gdbserver cp 到目标板上,然后运行
gdbserver ip : port ap
如:gdbserver 192.168.1.100:8888 test
192.168.1.100 为目标板的ip
8888为监听端口

test 为调试文件,程序在编译时包含调试信息. 在编译时用 -g 选项打开调试选项。


然后在host端运行 arm-linux-gdb test

target remote 192.168.1.230:8888

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics