gcc ?需要使用gdb調(diào)試時需要加-g選項
gdb選項
-q 不顯示版本信息
CoreFile
CoreFile可增強gdb調(diào)試能力
core文件是通用出錯內(nèi)存印象文件,默認情況下不生成core文件,需要在.bashrc中添加 ?ulimit -c unlimited 使修改生效: . .bashrc
gdb操作
where ? 出錯在哪一行
list ? ? 出錯行的上下文默認顯示10行
break 8 ?| ?main ?| ? hello.c:8 ? ? ? ? ? ? 加一個斷點
delete ? 刪除一個斷點
continue ? 命令從斷點以后繼續(xù)執(zhí)行
s(step) ? ? ? 單步調(diào)試
n(next) ? ? ? ? ? ?不進入函數(shù)跳到下一步
run ? ? ? ? ? ? ?執(zhí)行
print ?i ? ? ?變量的值
whatis i ? 變量類型
info break ?查看有什么斷點
set variable i=100 ? ? ? ? ?變量名更改變量的值
gdb界面模式
gdb -tui -q ?p2pserv