文章最后又GDB的安装方法!
在PC机下调试PC机程序:
gcc -g hello.c -o hello @-o Specified Specified exec name -g debugging message
gdb hello @debugging program
break orr b params @set breakpoint
b function name
b line numbers
b file name + line numbers
b line numbers + if condition is true
run @run program
print + variable name @display variable value
info break orr b @display all breakpoint numbers
delete breakpoint numbers @delete the numbers breakpoint
list orr l @display source code
next @step by step running ,don't Entry sub function
step @step by step running ,Entry sub function
continue orr c @high speed run as next breakpoint orr program end
finish @running program utile Current function end
watch + variable value @for the variable control
q @exit
在开发板上调试交叉编译下的程序:在远程下调试。
1、Download GDB source code
website:ftp://ftp.gnu.org/gnu/gdb
2、compile GDB
# tar -xzvf gdb-7.4.tar.gz
# cd gdb-7.4
# ./configure --target=arm-linux
#make
# mkdir tmp
# make install prefix=$PWD/tmp
#cp arm-linux-gdb /bin
3、install board gdbserver:
#cd gdb/gdbserver/
#./configure --host=arm-linux
#make (把生成的gdbserver复制到board的/bin目录下)
编译要调试的应用,编译时加上-g选项
4、cross compile gdbserver :
5、debug
Board ip = 210.41.141.111
Host pc ip = 210.41.141.155
Board:
#gdbserver 210.41.141.111:1111 ./test_debug /*1111为端口号,可以随便设置*/
host pc:
(由于交叉编译自带gdb工具,所以这里要指定路径,不然会冲突)
#/bin/arm-linux-gdb ./test_debug
(gdb)target remote 210.41.141.111:1111
....
链接成功后,gdb远程调试和gdb本地调试方法命令相同。