現在の 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 以外にすれば良い。


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

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

$ ulimit -c 0
$ ./segv
Segmentation fault
$ ulimit -c unlimited
$ ./segv
Segmentation fault (コアダンプ)
$ gdb ./segv core
GNU gdb (Debian 7.12-6)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>
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:
Find the GDB manual and other documentation resources online at:
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


$ ulimit -c unlimited
-bash: ulimit: core file size: cannot modify limit: Operation not permitted

添付ファイル: filesegv.tgz 1172件 [詳細]

トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2022-01-29 (土) 16:32:26