海思GDB8.3 + GDB Server调试

1、下载

下载地址:http://ftp.gnu.org/gnu/gdb/

镜像站点:https://mirrors.ustc.edu.cn/gnu/

2、解压并创建目录

tar -zxvf gdb-8.3.tar.gz

mkdir obj_gdb

mkdir obj_gdbserver

touch ./obj_gdb/build

touch ./obj_gdbserver/build

3、前期准备

8.0以后要依赖expat库,不装的话会运行时会出现如下错误:

(gdb) target remote 192.168.0.138:1234
Remote debugging using 192.168.0.138:1234
warning: Can not parse XML target description; XML support was disabled at compile time
Reading /lib/ld-linux-armhf.so.3 from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
Reading /lib/ld-linux-armhf.so.3 from remote target...
Reading symbols from target:/lib/ld-linux-armhf.so.3...done.
Remote 'g' packet reply is too long (expected 168 bytes, got 328 bytes): 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020fdffbe00000000007afdb6100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

linux下下载expat库:git clone https://github.com/libexpat/libexpat.git (网址:https://github.com/libexpat/libexpat)

得到libexpat

cd libexpat/expat

./buildconf.sh

#(如果出错./autogen.sh: autoreconf: not found,按照网址https://blog.****.net/mybelief321/article/details/9208073添加#autoreconf等工具

./configure --without-docbook --prefix=/usr/local/arm-gdb/expat_out

make & make install

4、编译

#GDB编译

cd obj_gdb

vi build

#填写以下内容

../gdb-8.3/configure --target=arm-hisiv600-linux --prefix=/home/lzl/1-tools/obj_gdb/install --with-expat --with-libexpat-prefix=/usr/local/arm-gdb/expat_out
make
make install

#GDB Server编译

cd obj_gdbserver

vi build

#填写以下内容

./gdb-8.3/gdb/gdbserver/configure --target=arm-hisiv600-linux --host=arm-hisiv600-linux                                                       make  CC=arm-hisiv600-linux-gcc

5、调试

 #方法1:

板子运行:

./gdbserver 192.168.2.190:1234 test

虚拟机运行:

./arm-hisiv600-linux-gdb

(gdb)  target remote 10.0.12.143:1234

(gdb) c

 海思GDB8.3 + GDB Server调试

#方法2:

使用core文件

https://blog.****.net/weixin_42535742/article/details/90545937

运行方式: ./arm-hisiv600-linux-gdb (运行文件) (core文件)

参考:

https://blog.****.net/wl1070325332/article/details/60876468/

https://blog.****.net/u011003120/article/details/102681778

https://blog.****.net/intjun/article/details/81353717

https://blog.****.net/dyzhen/article/details/53407000