===========================================================================================
cross compile
============================================================================================
1.下载GDB源码
ftp://ftp.gun.org/gun/gdb
2.编译需要的库termcap 和 gdb
step 1:
compiling termcap-1.3.1.tar.gz
$ tar zxvf termcap-1.3.1.tar.gz
$ cd termcap-1.3.1
$ mkdir -p /opt/termcap
$ ./configure --host=mipsel-linux --prefix=/opt/termcap
$ vi Makefile
CC = mipsel-linux-gcc
AR = mipsel-linux-ar
$ make
$ make install
$ cp /opt/termcap/include/* /opt/mipseltools-clx-26/mipsel-linux/include/
$ cp -a /opt/termcap/lib/* /opt/mipseltools-clx-26/mipsel-linux/lib/
step 2:
#cd /opt
#tar zxvf gdb-6.6.tar.gz
等待解压完毕,就会在/opt产生一个gdb-6.6的目录
step 3:
编译pc跑的mipsel-linux-gdb
建立你的安装目录,比如/opt下面
#mkdir -p /opt/gdb
#../gdb-6.6/gdb/configure --host=i686-linux --target=mipsel-linux --prefix=/opt/gdb
等待完毕........
#make
#make install
step 4:
编译开发板上跑的gdbserver
接着编译我们的gdbserver,他最终会运行在我们的开发板
同样我们在/opt下面建立我们的gdbserver安装目录
#mkdir -p /opt/gdbserver
#../gdb-6.6/gdb/gdbserver/configure --host=mips-linux --target=mipsel-linux --prefix=/opt/gdbserver
#make
#make install
#cp -a /opt/gdbserver/bin/* /nfsroot/cq8401-mg3500/usr/bin/
3.接下来就是怎么使用gdb和gdbserver
pc ip:192.168.4.200
board ip: 192.168.4.100
dir: /tmp/test.c
code compile: mipsel-linux-gcc -g test.c -o test
cp test test.c /nfsroot/cq8401/tmp
step 1:
board 端:
# cd /tmp
#gdbserver 192.168.4.200:2000 ./test
step 2:
pc 端:
# export PATH=$PATH:/opt/gdb/bin
# cd /lib
# ln -s /opt/mipseltools-clx-26/lib/ld.so.1 ld.so.1 //库的匹配
# ln -s /opt/mipseltools-clx-26/lib/ld.so.1 libc.so.6
# cd /tmp
# mips-linux-gdb ./test
(gdb) target remote 192.168.4.100:2000
接下来就是调试的具体过程了