checkpoint的內容參考:html
http://blog.chinaunix.net/uid-23629988-id-2943273.htmlexpress
這一篇主要是checkpoint,在next以前加checkpoint命令,而後就能夠用 restart 1 來恢復到以前的checkpoint,能夠避免從頭再來。函數
用 info checkpoints 能夠看到全部的checkpoints。ui
好像也能看到breakpoint的spa
(gdb) info checkpoints * 1 process 2060 at 0x80483e7, file test.c, line 33 0 process 2059 (main process) at 0x80483f7, file test.c, line 35
watch看.net
http://simohayha.iteye.com/blog/493091線程
watch是監測變量改變。watch expr [thread threadno] 是隻針對這個線程對變量的改變。debug
rwatch是針對變量被讀; awatch是針對變量被改變或者被讀。unix
break是斷點rest
tbreak是一次性的斷點。
break location if condition 是condition爲真的時候,到達這個location纔會生效。
rbreak是帶有regex的斷點。
catch event是當事件發生的時候,會生效,
這些事件包括了:throw, catch, exception, exception unhandled, assert, exec, fork, vfork等。
tcatch指一次性的catch.
一個斷點(包括 watchpoint和catchpoint)能夠有下面四種狀態. :
打開,關閉,enabled once,enabled for deletion
分別對應下面的:
disable [breakpoints][range..] 關閉指定的斷點或者所有斷點(若是沒有range)
enable [breakpoints][range..] 打開指定的斷點或者所有斷點(若是沒有range)
enable [breakpoints] once range 臨時打開指定的斷點(也就是說是一次性的,.
enable [breakpoints] delete range 臨時打開指定的斷點並只工做一次,也就是一次以後這個斷點將會被刪除.
clear刪除斷點,
clear location, 最經常使用的是:
clear function, clear file:function, clear linenum, clear file:linenum.
clear與delete的區別,clear是給出行號或者函數,而delete是給出斷點編號。
condition除了跟在break後面,也是能夠單獨做爲命令使用的:break condition
contidition bnum expression 當expression爲真的時候,程序到達這個斷點纔會中止.
contidition bnum 從斷點bnum刪除掉一個condition.
ignore bnum count 設置一個斷點bnum的忽略次數爲count.也就是隻有count次數後,這個斷點纔會起做用.
break裏面還能夠帶上一串命令:
break 403 commands ///不輸出任何東西 silent ///改變x的值 set x = y + 4 ///而後continue cont end
用commands + end 來實現
step [count]
加count,是step屢次,若是遇到斷點會中止。
next [count]
和step很相似,區別就是不會跟進函數。
step的行爲經過step-mode來控制:
on就能夠使step中止在沒有debug信息的函數的第一條指令上。off則是直接執行完這個函數。
這裏要注意上面的命令都只是跳一行代碼。而不是一條指令。
stepi是執行指令。nexti也是。
gdb能夠監測在你的程序中的任何信號。