- 论坛徽章:
- 0
|
来看看gdb调试的过程
- [xiaodao@dev t]$ gcc -g foo.c
- [xiaodao@dev t]$ gdb ./a.out
- GNU gdb Red Hat Linux (6.6-35.fc8rh)
- Copyright (C) 2006 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 "i386-redhat-linux-gnu"...
- Using host libthread_db library "/lib/libthread_db.so.1".
- (gdb) list
- 10 "\x50"
- 11 "\x53"
- 12 "\x89\xe1"
- 13 "\xb0\x0b"
- 14 "\xcd\x80"
- 15 ;
- 16
- 17 int main()
- 18 {
- 19 void (*fp)(void) = (void (*)(void))sc;
- (gdb)
- 20
- 21 printf("Length: %d\n",strlen(sc));
- 22 fp();
- 23 }
- (gdb) b 22
- Breakpoint 1 at 0x804840c: file foo.c, line 22.
- (gdb) r
- Starting program: /home/xiaodao/t/a.out
- warning: Missing the separate debug info file: /usr/lib/debug/.build-id/ac/2eeb206486bb7315d6ac4cd64de0cb50838ff6.debug
- warning: Missing the separate debug info file: /usr/lib/debug/.build-id/ba/4ea1118691c826426e9410cafb798f25cefad5.debug
- Length: 23
- Breakpoint 1, main () at foo.c:22
- 22 fp();
- (gdb) p sc
- $1 = "1hn/shh//bi\211?\211?v?200"
- (gdb) p &sc
- $2 = (char (*)[24]) 0x804966c
- (gdb) p fp
- $3 = (void (*)(void)) 0x804966c <sc>
- (gdb) p &fp
- $4 = (void (**)(void)) 0xbf8ed28c
- (gdb) n
- Program received signal SIGSEGV, Segmentation fault. //这里收到了SIGSEGV信号
- 0x0804840f in main () at foo.c:22
- 22 fp();
- (gdb)
复制代码 |
|