gdb如何确定内存 已经释放_GDB内存断点(Memory break)的使用举例

$ gcc -g -o membreak testMemBreak.c

$ gdb ./membreak.exe

GNU gdb 6.3.50_2004-12-28-cvs (cygwin-special)

Copyright 2004 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 "i686-pc-cygwin"...

(gdb) l

1#include

2#include

3

4int main()

5{

6int i,j;

7char buf[256]={0};

8char* pp = buf;

9

10printf("buf addr= 0x%x\r\n",buf);

(gdb)

11for(i=0;i<16;i++)

12{

13printf("addr = 0x%x ~ 0x%x\r\n",pp+i*16,pp+i*16+15);

14for(j=0;j<16;j++)

15*(pp+i*16+j)=i*16+j;

16}

17

18printf("ASCII table:\n");

19for(i=0;i<16;i++)

20{

(gdb)

21for(j=0;j<16;j++)

22printf("%c", *(pp+i*16+j));

23printf("\n");

24}

25

26return 0;

27}

(gdb) b 10

Breakpoint 1 at 0x4010ae: file testMemBreak.c, line 10.

(gdb) r

Starting program: /cygdrive/e/study/programming/linux/2009-12-28 testMemBreak/membreak.exe

Breakpoint 1, main () at testMemBreak.c:10

10printf("buf addr= 0x%x\r\n",buf);

(gdb) step

buf addr= 0x22cb70

11for(i=0;i<16;i++)

(gdb) p buf

$1 = '\0'

(gdb) p &buf

$2 = (char (*)[256]) 0x22cb70

(gdb) display &buf

1: &buf = (char (*)[256]) 0x22cb70

(gdb) p/x *0x22cb70@64

$3 = {0x0 }

(gdb) x/64w 0x22cb70

0x22cb70:0x000000000x000000000x000000000x00000000

0x22cb80:0x000000000x000000000x000000000x00000000

0x22cb90:0x000000000x000000000x000000000x00000000

0x22cba0:0x000000000x000000000x000000000x00000000

0x22cbb0:0x000000000x000000000x000000000x00000000

0x22cbc0:0x000000000x000000000x000000000x00000000

0x22cbd0:0x000000000x000000000x000000000x00000000

0x22cbe0:0x000000000x000000000x000000000x00000000

0x22cbf0:0x000000000x000000000x000000000x00000000

0x22cc00:0x000000000x000000000x000000000x00000000

0x22cc10:0x000000000x000000000x000000000x00000000

0x22cc20:0x000000000x000000000x000000000x00000000

0x22cc30:0x000000000x000000000x000000000x00000000

0x22cc40:0x000000000x000000000x000000000x00000000

0x22cc50:0x000000000x000000000x000000000x00000000

0x22cc60:0x000000000x000000000x000000000x00000000

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值