設定環境
Host (PC)(Ubuntu)
安裝Cross-Compile GDB & GDB Server
- 下載GDB Source (內含GDB & GDB Server)
http://www.gnu.org/software/gdb/download/
- 下載GDB Source (內含GDB & GDB Server)
Complier GDB
cd <GDB source> ./configure make
Cross-compiler GDB Server
cd <GDB Src>/gdbserver ./configure --host=mipsel-linux make
安裝CGDB方便操作GDB
sudo apt-get install cgdb
Cross-compile
with GCC Debug option “-g”
Target board
- 將
放在target board - 將
放在target board
- 將
進行Remote debug
- Target board
GDB Server 設定Listen Port
<cross-compiled gdbserver> localhost:<port> <cross-compiled application>
- Host
使用CGDB啟動GDB
cgdb -d <cross-compiled gdb> <cross-compiled application>
切換至GDB模式
CGDB與GDB模式互換
- GDB->CGDB: 按下”esc”
- CGDB->GDB: 按下”i”
GCC Debug command連上GDB Server
target remote <target board IP>:<target board port>
GCC Debug command
- list (l) –顯示程式
- continue (c) – 離開中斷點,繼續執行程式
- run (r) – 開始執行程式
- next (n) – Step over
- next (s) – Step in