一、編譯文件時(shí)加-g
g++ *.cpp -g -o test
二、基本命令
1、啟動(dòng)調(diào)試
gdb test
gdb -q test //表示不打印gdb版本信息,界面較為干凈;
2、啟動(dòng)程序 run = r
3、繼續(xù)執(zhí)行至下一斷點(diǎn)或程序結(jié)束 continue = c
4、執(zhí)行一行代碼,此行代碼中有函數(shù)調(diào)用則進(jìn)入 step = s
5、執(zhí)行一行代碼,此行代碼中的函度數(shù)調(diào)用也一并執(zhí)行 next = n
6、退出gdb quit = q
三、斷點(diǎn)
1、設(shè)置斷點(diǎn) break file1.cpp:65 // 在file1.cpp的第65行設(shè)置斷點(diǎn)
2、查看斷點(diǎn) info b