Posted by: kezhong | May 29, 2009

Core Dump Lab

In computing, a core dump consists of the recorded state of the working memory of a computer program at a specific time, generally when the program has terminated abnormally (crashed).

Core dumps are often used to diagnose or debug errors in computer programs.

Check and modify the size of core file

$ ulimit -c
0

$ ulimit -c 1000

$ ulimit -c
1000

Edit a program for testing

/*core_dump_test.c*/

1 #include <stdio.h>
2
3 int main()
4 {
5 printf(“%s\n”,9);
6 return 0;
7 }

Compile

$ gcc –g core_dump_test.c -o core_dump_test

Run

$ ./core_dump_test
Segmentation fault (core dumped)

Search

$ ls core.*
core.2153

Debug

$ gdb core_dump_test core.2153

… …

(gdb) where

#0 0x00a1971b in strlen () from /lib/libc.so.6
#1 0x009e640f in vfprintf () from /lib/libc.so.6
#2 0x009ec6d0 in printf () from /lib/libc.so.6
#3 0x080483e9 in main () at cdtest.c:5

Reference

http://en.wikipedia.org/wiki/Core_dump

http://blog.csdn.net/iori97king/archive/2008/10/27/3158133.aspx


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: