coreファイルの生成方法

現在の debian 等ではデフォルトで、core ファイルを生成しない。
ulimit で設定を変える必要がある。(ulimit は shellの機能)

$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 15663
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 15663
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

core file size のブロックサイズを 0 以外にすれば良い。

上記のテストコードでSEGVを発生させてみる。

$ gcc -o segv segv.c
$ ./segv
Segmentation fault

当然、core ファイルは生成されない。そこで、サイズを無制限にして実行

$ ulimit -c unlimited
$ ./segv
Segmentation fault
$ ulimit -c unlimited
$ ./segv
Segmentation fault (コアダンプ)
$ gdb ./segv core
GNU gdb (Debian 7.12-6) 7.12.0.20161007-git
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./segv...(no debugging symbols found)...done.
[New LWP 2147]
Core was generated by `./segv'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000055bcc1e696b9 in main ()
(gdb) q
$



トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS