1、开始调试
编译时带-g为调试,带调试信息编译后的可执行文件更大

2、进入调试
使用gdb 可执行文件名------进入调试
失败版:

成功版:

3、l命令
l什么都不加------列出10行代码

l 行号------行号的行在中间,向上向下展示10行
4、start
开始调试,断点默认停在main函数第一行

5、下一步调试
逐过程:next,如果调用其他函数,也不进入,直接进入下一条语句

逐语句:step,遇见函数进入

6、打印变量值
p 变量名
display 变量名------持续打印变量值

结束监控:undisplay 变量号

7、结束调试

8、重新开始

9、下断点
b 行号

10、run
停在第一个断点处,开始调试
11、查看所有断点信息

12、继续
continue 继续到下一个断点处
13、禁用断点和重新使用


1、makefile

2、测试makefile文件(1)
(1)准备一个main文件

(2)写makefile文件

version是版本号
myapp是要生成的可执行文件的名字,main.c是依赖文件的名字
下面是和外面一样的编译命令


如果没有修改,不会重新编译
3、测试文件(2)
makefile文件

在已经生成后,修改一个文件,重新执行时只会重新编译修改的文件,其余不会变

4、执行原理和注意事项






解决路径中空格的问题,写脚本时,不要留空格
