LoginSignup
1
1

More than 5 years have passed since last update.

実践デバッグ技法を読んでの気付き vol.1 coreファイルについて

Last updated at Posted at 2014-02-10

coreファイルについて

実践デバッグ技法を読んでの気付きというなの備忘録。

coreファイルとは

UNIX系OSにおいて、プログラムがエラーにより不正終了する際に、
メモリやレジスタの内容をディスクに記録すること。
もしくは記録したファイル。

参照:e-Words コアダンプより

coreファイルを出力するサンプルプログラム

sigsegv.c

#include <stdio.h>

int main( void )
{
  char* c = 0;
  printf( "%s/n", *c );

  return 0;
}

coreファイルの出力確認

【コマンド】

$ ulimit -a

【出力結果】
core file size (blocks, -c) 0 ※※※ 「0」の場合は出力されません。
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 256
pipe size (512 bytes, -p) 1
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 709
virtual memory (kbytes, -v) unlimited

coreファイルの出力設定

【コマンド】

$ ulimit -c unlimited

【出力結果】
core file size (blocks, -c) unlimited ※※※ 先程、「0」だったものが、 unlimited となっている
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 256
pipe size (512 bytes, -p) 1
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 709
virtual memory (kbytes, -v) unlimited

サンプルプログラムのコンパイル

【コマンド】

$ gcc -g sigsegv.c -o sigsegv.out

サンプルプログラムの実行(coreファイルを出力してみる)

【コマンド】

$ ./sigsegv.out

【実行結果】

drwxrwxr-t@ 3 root admin 102B 2 10 20:55 .
drwxr-xr-x 29 root wheel 1.0K 4 4 2013 ..
-r-------- 1 **** admin 351M 2 10 20:55 core.1378

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1