2012年4月23日 星期一

Remote GDB debug紀錄

要先使用make menuconfig將gdbserver打開
make menuconfig -> Load config Cisco
Debug selection -> Build GDBserver for application debugging ->Save
然後重新編譯image之後燒到版子上,gdbserver會在/bin底下
ps:如果自己的SDK裡面沒有則需要自行cross compile


由於要debug telnet斷線問題,所以必須先利用gdbserver將板子上面想debug的app啟動

在target端
ps查看telnetd行程
./gdbserver :2000 --attach 1050  //觀察PID 1050的telnetd,開的port為2000

接著在PC端
切到要debug的路徑下
cd userspace/private/apps/telnetd/

讀取尚未strip過的exe
/opt/toolchains/uclibc-crosstools-gcc-4.4.2-1/usr/bin/mips-linux-uclibc-gdb telnetd

設定lib位置,這樣gdb才會知道去哪找到程式碼
(gdb)set solib-absolute-prefix xxx/fs
(gdb)set solib-search-path xxx/lib

連接到剛剛用gdbserver啟動的路徑
(gdb)target remote 192.168.1.1:2000

設定中斷點
(gdb)break foo
使用continue繼續執行,如果打run看起來會讓gdb不知道如何跑就結束了~"~
(gdb)c
可以使用bt去看目前的static
然後用n一步一步去執行

沒有留言: