b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

gdb 条件断点_gdb watch_gdb 条件断点 内存

电脑杂谈  发布时间:2017-04-10 23:05:12  来源:网络整理

一个调试示例

——————

源程序:tst.c

1 #include <stdio.h>

2

3 int func(int n)

4 {

5int sum=0,i;

6for(i=0; i<n; i)

7{

8sum=i;

9}

10return sum;

11 }

12

13

14 main()

15 {

16int i;

17long result = 0;

18for(i=1; i<=100; i)

19{

20result = i;

21}

22

23printf("result[1-100] = %d /n", result );

24printf("result[1-250] = %d /n", func(250) );

25 }

编译生成执行文件:(Linux下)

hchen/test> cc -g tst.c -o tst

使用GDB调试:

hchen/test> gdb tst<----------启动GDB

GNU gdb 5.1.1

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-suse-linux"...

(gdb) l<-------------------- l命令相当于list,从第一行开始例出原码。

1#include <stdio.h>

2

3int func(int n)

4{

5int sum=0,i;

6for(i=0; i<n; i)

7{

8sum=i;

9}

10return sum;

(gdb)<--------------------直接回车表示,重复上一次命令

11}

12

13

14main()

15{

16int i;

17long result = 0;

18for(i=1; i<=100; i)

19{

20result = i;

(gdb) break 16<--------------------设置断点,在源程序第16行处。

Breakpoint 1 at 0x8048496: file tst.c, line 16.

(gdb) break func<--------------------设置断点,在函数func()入口处。

Breakpoint 2 at 0x8048456: file tst.c, line 5.

(gdb) info break<--------------------查看断点信息。

Num TypeDisp Enb AddressWhat

1breakpointkeep y0x08048496 in main at tst.c:16


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-40593-1.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...