由於廠商並未提供arm上面的gdb,所以必須自行編譯gdb。
編譯的流程主要參考OPENCSL ,簡略的紀錄我的過程
TARGET:S3C6410
Toolchain: gcc-4.2.2-eabi
流程:
# get new version from http://ftp.gnu.org/gnu/gdb (我下載的是gdb-7.0.1.tar.bz2)
# tar jxvf gdb-7.0.1.tar.bz2
# cd gdb-7.0.1
# mkdir gdb-host gdb-target
# cd gdb-host
# ../configure --target=arm-linux --prefix=$(pwd)
# make
# make install (arm-linux-gdb in bin directory)
# cd gdb-target
# CC=arm-linux-gcc ../gdb/gdbserver/configure --host=arm-linux --prefix=$(pwd)
# make (gdbserver in .)
由於我產生的gdb是使用shared-library所以要把toolchain的library燒到版子。
進行遠端除錯:
ARM:
$ ./gdbserver 192.168.0.53:3333 mplayer -ac mad -vo fbdev test.mpg
Process mplayer created; pid = 910
Listening on port 3333
PC:
# /gdb-7.0.1/gdb-host/bin/arm-linux-gdb mplayer
(gdb) target remote 192.168.0.100:3333 (連上TARGET的IP)
(gdb) b main
(gdb) r
The "remote" target does not support "run". Try "help target" or "continue".
run好像不能用,用continue
(gdb) c
Breakpoint 1, main (argc=6, argv=0xbef7fe24) at mplayer.c:2282
接下來就可自行debug
參考資料:
OPENCSL
GDB指令快查