标签:
rpm -ivh gdb-7.2-56.el6.i686.rpm
ulimit -c unlimited
#include <stdio.h> void test(void) { int *I = NULL; *i = 2; } int main(void) { printf(“hello world\n”); test(); return 0; }
gcc –g –o hello hello.c
Segmentation fault (core dumped)
ls
core.3563 hello hello.c
gdb hello core.3563
gdb -q hello core.3563
#0 0x08048394 in test () at hello.c:5
5 *i = 2;
gdb hello
Starting program: /home/test/1/hello
hello world
Program received signal SIGSEGV, Segmentation fault.
0x08048394 in test () at hello.c:5
5 *i = 2;
#0 0x08048394 in test () at hello.c:5
#1 0x080483be in main () at hello.c:11
1 #include <stdio.h>
2 void test(void)
3 {
4 int *i = NULL;
5 *i = 2;
6 }
7
8 int main(void)
9 {
10 printf("hello world\n");
#0 0x08048394 in test () at hello.c:5
#1 0x080483be in main () at hello.c:11
(gdb) print i
$1 = (int *) 0x0
(gdb) whatis i
type = int *
(gdb) break 4
Breakpoint 1 at 0x804838a: file hello.c, line 4.
(gdb) run
Starting program: /home/test/1/hello
hello world
Breakpoint 1, test () at hello.c:4
4 int *i = NULL;
(gdb) info break
Num Type Disp Enb Address What
1 breakpoint keep y 0x0804838a in test at hello.c:4
breakpoint already hit 1 time
set variable varname = value
标签:
原文地址:http://www.cnblogs.com/shichuan/p/4475176.html