1.建構 remote gdb + gdbserver 環境 for arm
2.常用gdb指令
3.core dump
參考資料
1.Debugging a Linux Application with MontaVista 5.0
2.DAVINCI调试ARM端应用程序
3.arm-linux-gdb+gdbserver环境搭建以及远程调试 及调试core文件
4.GDB指令
5.gdb stops at SIGPIPE
6.打開 core dump 和使用 cgdb 檢查程式掛點原因
7.產生 core dump 的方法
8.setting the core dump name schema
9.http://sourceware.org/gdb/wiki/FAQ
常用gdb指令
一般設定
- set solib-absolute-prefix /path 設定預設存取share lib 路徑
- handle SIGPIPE nostop 遇到SIGPIPE signal不跳出停止
- set height 0 設定screen 無限制瀏覽 中間不會詢問停止瀏覽
- add-symbol-file [FILE] [ADDR] 增加share lib symbol
- core [core file]
-- 利用core file來Debug程式 - target remote [remote ip]:[port]
-- 連線Remote ip來Devug程式 - gdbserver [ip]:[port] [program] [program arg] -- 遠端gdb server設定
- info threads -- 顯示目前所有的 thread
- thread [thread_num] -- 切換 GDB 到指定的 thread_num
圖形化
- wh --啟動圖形化介面
- ctl+x+a or ctl+x+A -- 取消圖形化介面
- break 簡寫指令 b
- break (b) [line_number] -- 在指定的行數設定中斷點
- break [function] -- 在指定的 function 設定中斷點。e.g. break main
- break [filename:line_num] -- 在指定檔案的指定行數設定中斷點。e.g. break main.c:10
- break [LOCATION] [if CONDITION] -- 條件式中斷點,當 CONDITION 滿足時才中斷。 e.g. break main.c:10 if var > 10
- info break -- 列出所有的中斷點及編號
- delete [number] -- 刪除指定編號的中斷點
- disable [number] -- 使指定編號的中斷點失效
- enable [number] -- 取消 disable,使指定編號的中斷點生效
- commands [breakpoint num] -- 設定遇到中斷點要下的指令,以end結束,例如:
break 200 if x>0 commands printf "x is %d/n",x continue end
Core Dump 設定
在下面兩個檔案加上內容
1. /etc/sysctl.conf
kernel.core_uses_pid = 0 kernel.core_pattern = /tmp/core.%e.%p.%t
2.執行sysctl -p
或是直接執行sysctl -w kernel.core_pattern=/tmp/core.%e.%p.%t
3. 這時候/proc/sys/kernel/core_pattern內容就會如下
/tmp/core.%e.%p.%t
再來在系統執行時加上ulimit指令設定
4. /etc/init.d/rc.sysinit
ulimit -c unlimited
之後DEBUG模式的程式產生core dump後就可以用gdp來分析
測試
若執行的程式有讀 terminal input, 可直接輸入 ctrl + \ 送出 SIGQUIT。或用指令 kill -QUIT PID 或 kill -ABRT PID, 要求程式產生 core dump, 藉此測試目前的設定是否 ok。
沒有留言:
張貼留言