建立嵌入式gdb调试环境
一.下载gdb-7.1.tar.gz源代码
phil@ubuntu-embedded:~/gdb-7.1$ wget http://ftp.gnu.org/gnu/gdb/gdb-7.1.tar.gz
二.编译 GDB
#tar zxvf gdb-7.1.tar.gz
2.1 编译GDB Client
phil@ubuntu-embedded:~/gdb-7.1$ cd gdb-7.1/
phil@ubuntu-embedded:~/gdb-7.1$ ./configure --target=arm-linux --prerix=`pwd`/rls
phil@ubuntu-embedded:~/gdb-7.1$ make
phil@ubuntu-embedded:~/gdb-7.1$ make install
phil@ubuntu-embedded:~/gdb-7.1$ ls rls/bin/
arm-linux-gdb arm-linux-gdbtui arm-linux-run
phil@ubuntu-embedded:~/gdb-7.1$ file rls/bin/arm-linux-gdb
rls/bin/arm-linux-gdb: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
2.2 编译GDB Server
#cd ./gdb/gdbserver
#./configure --target=arm-linux --host=arm-linux
三.实战调试
1.编辑文件
# vi gdbtest.c
#include <stdio.h>
int
func(int n){
int sum=0, i;
for (i=0; i<n; i++){
sum += i;
}
return sum;
}
int
main(void)