gdb移植(交叉版本)

Gdb下载地址:

http://ftp.gnu.org/gnu/gdb/

termcap下载地址:
http://ftp.gnu.org/gnu/termcap/
tar -zxvf termcap-1.3.1.tar.gz


1.编译termcap-1.3.1
a)./configure --host=arm-linux --prefix=/home/jkf5773/workspace/gdb/gdb-2/install --without-ada --enable-termcap --with-shared
若是其他例如mips平台,则--host=mipsel-linux
b) make
c) make install
2.编译gdb-7.6
a)./configure --host=arm-linux --enable-shared --prefix=/home/jkf5773/workspace/gdb/gdb-2/install --without-x --disable-gdbtk --disable-tui --without-included-regex --without-included-gettext LDFLAGS="-L/home/jkf5773/workspace/gdb/gdb-2/install/lib" CPPFLAGS="-I/home/jkf5773/workspace/gdb/gdb-2/install/include"
若是其他例如mips平台,则--host=mipsel-linux
b) make
c) make install
d) 在gdb-7.6gdb下可以找到gdb可执行程序,在gdb-7.6gdbgdbserver下可以找到gdbserver可执行程序,
将该gdb命令命名为arm-linux-gdb gdbserver命名为arm-linux-gdbserver

3、gdb交叉版本使用
设备IP:192.168.1.110
PCIP:192.168.1.5
a)设备端
./arm-linux-gdbserver  192.168.1.110:1234 hello
b)PC电脑端
arm-linux-gdb hello
c)进入gdb后远程到设备
target remote 192.168.1.110:1234
d)连接成功后
PC端提示:
 Remote debugging using 192.168.1.110:1234
 Malformed packet(b) (missing colon): ore:0;
 Packet: 'T050b:00000000;0d:30edf4be;0f:b0f70040;thread:3cb;core:0;'
设备端提示:
 Remote debugging from host 192.168.1.5
 readchar: Got EOF
 Remote side has terminated connection.  GDBserver will reopen the connection.
 Listening on port 1234

交叉版本GDB : arm-linux-gdbserver在设备端运行,gdb在PC端运行,arm-linux-gdbserver文件比较小,所以占用设备内存空间小
而本地版本GDB :  arm-linux-gdb在设备端运行文件较大

原文地址:https://www.cnblogs.com/baiduboy/p/7616606.html