標籤:step 退出 http 修改 開始 ignore 語句 啟動 tar
一、啟動調試
測試程式
1 #include<iostream> 2 using namespace std; 3 class AA 4 { 5 void f(){} 6 }; 7 int main() 8 { 9 cout<<sizeof(AA)<<endl; 10 AA a; 11 cout<<sizeof(a); 12 return 0; 13 }
g++/gcc 命令加-g表示使用了gdb調試:
file+產生的可執行檔(test):匯入調試檔案
二、常用調試命令(斷點調試)
r 開始執行(run),如果有斷點則直至第一個斷點(break)
b 設定斷點
b num(行號)
b function(函數名)
tb 斷點位置 設定臨時斷點(只生效一次)
i b 檢查斷點資訊
b 斷點位置 if 條件 設定條件斷點
ignore bnum count 表示接下來的count編號為bnum的斷點忽略。
d 斷點編號 刪除斷點(delete)
c 斷點之後繼續執行到下一個斷點(continue)
n 單步運行(next)
s 進入函數(step)
finish 執行至退出函數
start 停留在main函數的第一條語句
p 參數 列印參數資訊
info 檔案/函數 檔案/函數資訊
三 、設定觀察點
修改了一下測試檔案
1 #include<iostream> 2 using namespace std; 3 class AA 4 { 5 void f(){} 6 }; 7 int main() 8 { 9 int b=1; 10 for(int i=1;i<10;i++) 11 b++; 12 cout<<sizeof(AA)<<endl; 13 AA a; 14 cout<<sizeof(a); 15 return 0; 16 }
watch 觀察點 (遇到變數值變化,程式就會停下來)
i watch 查看觀察點
d 序號 刪除觀察點
四、退出
q
gdb調試小結