[root@localhost home]# mkdir gdb //创建gdb文件夹
[root@localhost gdb]# vim gdb.c
[root@localhost gdb]# gcc gdb.c -o gdb -g //调试
[root@localhost gdb]# gdb gdb //进入调试界面
GNU gdb Red Hat Linux (6.5-25.el5rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) //光标所在行
l:(List)显示前十行代码
l5:显示第五行的前五行和后五行
l:继续显示
r:运行
b 10:(break)在第十行打断点
r:运行到第十行
c:(continue)继续运行
info bereak:显示断点
delete b 1:删除第一个断点
b main:在main函数打断点
n:运行到下一行,遇到函数一起执行
step:遇到函数进入函数
p c:打印出c的值