官网:https://www.gnu.org/software/gdb/ Debugging with GDB:https://sourceware.org/gdb/current/onlinedocs/gdb/
简介
GDB, the GNU Project debugger, allows you to see what is going on `inside’ another program while it executes – or what another program was doing at the moment it crashed.
GDB的功能:
Start your program, specifying anything that might affect its behavior. Make your program stop on specified conditions. Examine what has happened, when your program has stopped. Change things in your program, so you can experiment with correcting the effects of one bug and go on to learn about another.
启动gdb
启动gdb之前,需要编译出debug版本的程序,编译时加-g选项
$ gcc -g main.c
启动方法:
调试直接启动程序 调试一个正在运行的程序,attach 调试core文件
调试直接启动程序:
语法: gdb$ gdb a.out
调试一个正在运行的程序,attach:
语法: gdb$ gdb a.out 11127
<


