新路程------GDB 调试(1)

本文介绍如何在Ubuntu系统中安装和配置GDB调试工具,包括必要的依赖库安装、编译步骤及针对不同目标平台(如海思、imx6等)的GDBserver定制方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  首先下载gdb-7.12.tar.gz(在我的资源中可以直接下载)

 然后解压到任意目录,我解压在Document里matt@ubuntu:~$ tar -zxvf gdb-7.12.tar.gz

 然后cd gdb-7.12然后

matt@ubuntu:~/Documents/gdb-7.12$ ./configure

在此之前我安装了

texinfo,libncurses5-dev, m4, flex 和 bison这5个包
就是apt-get install texinfo之类的cmd就可以了
然后

 matt@ubuntu:~/Documents/gdb-7.12$ make

然后

matt@ubuntu:~/Documents/gdb-7.12$ sudo make install

这样就装好了gdb

不过ubuntu14.04自带gdb,所以这个安装过程也只供参考


如果编译海思的gdb server,则命令如下:

matt@ubuntu:~/Documents/gdb-7.12/gdb/gdbserver$ CC=arm-hisiv300-linux-gcc ./configure --host=arm-hisiv300-linux  --target=arm-hisiv300-linux


matt@ubuntu:~/Documents/gdb-7.12/gdb/gdbserver$ make


matt@ubuntu:~/Documents/gdb-7.12/gdb/gdbserver$ file gdbserver
gdbserver: ELF 32-bit LSB  executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), not stripped


matt@ubuntu:~/Documents/gdb-7.12/gdb/gdbserver$ arm-hisiv300-linux-strip gdbserver -o gdbserver
matt@ubuntu:~/Documents/gdb-7.12/gdb/gdbserver$ file gdbserver
gdbserver: ELF 32-bit LSB  executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), stripped


而编译imx6的gdb server则是:

matt@ubuntu:~/Documents/gdb-7.12/gdb/gdbserver$ CC=arm-fsl-linux-gnueabi-gcc ./configure --host=arm-fsl-linux-gnueabi  --target=arm-fsl-linux-gnueabi

arm-fsl-linux-gnueabi-strip gdbserver -o gdbserver

而但凡目标开发板是arm内核的,gdb的编译命令都是

root@P310:~/Documents/gdb-7.12# ./configure --target=arm-linux --prefix=/usr/local/arm-gdb  后面这个是生成arm-linux-gdb的目录

在这个目录下执行

root@P310:/usr/local/arm-gdb/bin# gdb
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
Copyright (C) 2012 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 "i686-linux-gnu". //由于我们没有将新的arm-linux-gdb写入系统的环境变量中,所以这里用的还是默认的gdb也就是i686系统的gdb
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>.
(gdb) q
root@P310:/usr/local/arm-gdb/bin# ./arm-linux-gdb 
GNU gdb (GDB) 7.12
Copyright (C) 2016 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".  //这里多出来一个target哦
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值