gdb和arm-linux-gdb命令詳解
分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow
也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!
在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
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本地除錯方法命令相同。