使用gdbserver远程调试

参考网址1:http://www.cnblogs.com/pengdonglin137/p/4737045.html#_labelTop

 参考网址2:https://blog.csdn.net/wendaotaoa/article/details/8152864

一、利用GDB进行远程调试,首先需要明确以下几点:

1、调试用的GDB必须是交叉编译产生的GDB;

2、调试的程序必须是交叉编译且带 “-g” 选项的可执行程序。

3、在宿主机和目标开发板上调试的必须是同一个可执行程序。

4、基于 3 ,我们必须要建立一个宿主机和开发板的NFS共享目录,以实现调试调试同一可执行程序。(有待确认,也可以把可执行程序拷贝到目标板)

5、目标开发板的gdbserver和宿主机用的GDB版本必须相同,最好是同一源文件编译同时产生的。

6、在开发板上必须开通远程调试所需要的端口,否则远程调试机无法通过端口远程连接到开发板上。

 

二、安装gdbserver

1、准备材料

  1)操作系统:ubuntu16.04.1(64位)

  2)交叉编译器:gcc version 4.9.3 20141031 (prerelease) (Linaro GCC 2014.11) 

  3)gdb源码:gdb-7.8.tar.gz(gdb下载地址

2、编译过程 

# cd gdb-6.7.1/gdb/gdbserver/ 
#./configure --host=arm-linux-gnueabihf --prefix=$DEV_ROOT/gdb_7.8/install
#make 
#make install

3、编译错误

  1)错误1:

configure: error: no termcap library found
Makefile:8639: recipe for target 'configure-gdb' failed
make[1]: *** [configure-gdb] Error 1
make[1]: Leaving directory '/home/cjb/MYD-Y6ULX-devel/gdb-7.8/gdb-7.8'
Makefile:832: recipe for target 'all' failed
make: *** [all] Error 2

    解决:

      a, termcap库问题,参考网址:(点这里

This example shows how to succeed when you find a target-native termcap library is missing (cross building is somewhat different here -- use ./configure --help when in doubt):

cd ~/work/cross/gdb/downloads
wget ftp://ftp.gnu.org/gnu/termcap/termcap-1.3.1.tar.gz
cd ..
tar xvzf downloads/termcap-1.3.1.tar.gz
mkdir -p ~/work/cross/gdb/build/termcap
cd ~/work/cross/gdb/build/termcap

export CC=powerpc-7450-linux-gnu-gcc
export RANLIB=powerpc-7450-linux-gnu-ranlib
../../termcap-1.3.1/configure --host=powerpc-7450-linux-gnu --prefix=$HOME/work/cross/termcap
make
make install

    2)错误2:

      

原文地址:https://www.cnblogs.com/shanyu20/p/10916431.html