linux gdb

linux gdb

测试代码

#include <stdio.h>
#include <stdlib.h>
static char buf[255];
static char *str;
int main()
{
        printf("Please input a string:
");
        gets(str);
        printf("The string is %s
",str);
}

断点设置

1. 设置断点 
	使用break + 行号
	
2. 显示断点
     使用info breakpoint

3. 删除断点
     delete 断点号

 

具体实现
具体实现

 

关于程序执行过程中值的显示

	print
		参数为要显示的变量
		或者可以为表达式
		eg
		     print i*j
	         print array[0]@10   从基址开始的10个值。
	display   可以事先定义要显示的表达式 其余同上
	                   当到达断点处,自动显示预设表达式的值
    注意表达式可以修改变量的值

 

使用display设置断点
使用display设置断点

 

 

断点处自动显示display表达式
断点处自动显示display表达式

 

 

利用print修改变量的值,使程序正常执行
利用print修改变量的值,使程序正常执行

 

原文地址:https://www.cnblogs.com/Howbin/p/10654468.html