分类:
2011-05-31 10:42:07
原文地址:掌握 Linux 调试技术 作者:landuochong
代码: |
#include #include #include "memwatch.h" int main(void) { char *ptr1; char *ptr2; ptr1 = malloc(512); ptr2 = malloc(512); ptr2 = ptr1; free(ptr2); free(ptr1); } |
代码: |
#include #include int main(void) { char *ptr1; char *ptr2; char *chptr; int i = 1; ptr1 = malloc(512); ptr2 = malloc(512); chptr = (char *)malloc(512); for (i; i <= 512; i++) { chptr[i] = 'S'; } ptr2 = ptr1; free(ptr2); free(ptr1); free(chptr); } |
代码: |
set remotebaud 115200 symbol-file vmlinux target remote /dev/ttyS0 set output-radix 16 |
代码: |
int jfs_mount(struct super_block *sb) { ... int ptr; /* line 1 added */ jFYI(1, ("\nMount JFS\n")); / * * read/validate superblock * (initialize mount inode from the superblock) * / if ((rc = chkSuper(sb))) { goto errout20; } 108 ptr=0; /* line 2 added */ 109 printk("%d\n",*ptr); /* line 3 added */ |
代码: |
109 printk("%d\n",*ptr); objdump jfs_mount.o jfs_mount.o: file format elf32-i386 Disassembly of section .text: 00000000 : 0:55 push %ebp ... 2c: e8 cf 03 00 00 call 400 31: 89 c3 mov %eax,%ebx 33: 58 pop %eax 34: 85 db test %ebx,%ebx 36: 0f 85 55 02 00 00 jne 291 3c: 8b 2d 00 00 00 00 mov 0x0,%ebp << problem line above 42: 55 push %ebp |