rpm -qa | grep gdb
rpm -ivh gdb-7.2-56.el6.i686.rpm程序員
ulimit -c unlimitedbash
#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)spa
ls翻譯
core.3563 hello hello.cdebug
gdb hello core.3563指針
gdb -q hello core.3563調試
#0 0x08048394 in test () at hello.c:5code
5 *i = 2;blog
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