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一步一步去執行

傳檔案到版子上的方法

先起個頭,主要是想找出除了用傳統usb傳檔或者重編譯image燒錄的路
有一些原因是因為某些版子沒有usb port只能單純用網路...

方便性上來說NFS>TFTP>FTP>SFTP>USB

1.NFS
需求
1.nfs client on target
2.nfs server on host
2.portmap
目前只有在STB版子上能使用
Ex:
mount -t nfs 192.168.1.100:/mntshare /mnt/nfs

2.TFTP
需求
1.tftp client on target
2.tftp server on host

將檔案從host端get下來
tftp -g 192.168.1.100 -r myfile.txt

3.FTP
需求
1.ftp server on target
2.ftp client on host
經驗上來說如果版子上是server的話傳大量資料比較方便...畢竟windows FTP client軟體這麼多,用拖拉傳檔是不是比較爽

4.SFTP
需求
1.openssh server on target
2.winscp on host

主要effort必須porting openssh上板子並且別關閉sftp的功能

5.USB disk
需求
1.usb disk *1並且你的版子要有usb的孔
2.usb storage drive on target

通常有些版子有auto_mount的設計
插上去都會自動偵測到,如果沒有的話就要手動mount