===========================================================================================
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
接下來就是調試的具體過程了