coreファイルの生成方法
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
* coreファイルの生成方法 [#d217e5aa]
現在の 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 以外にすれば良い。
#highlight(c){{
#include <stdio.h>
#include <stdint.h>
int main(void)
{
printf("%d\n", *(int *)0);
return 0;
}
}}
#highlight(end)
#ref(segv.tgz)
上記のテストコードでSEGVを発生させてみる。
$ 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) 7.12.0.20161007-git
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.o...
This is free software: you are free to change and redist...
There is NO WARRANTY, to the extent permitted by law. T...
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 on...
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "w...
Reading symbols from ./segv...(no debugging symbols foun...
[New LWP 2147]
Core was generated by `./segv'.
Program terminated with signal SIGSEGV, Segmentation fau...
#0 0x000055bcc1e696b9 in main ()
(gdb) q
$
なお、sshでログインした環境だと、2回目の実行に失敗するこ...
$ ulimit -c unlimited
-bash: ulimit: core file size: cannot modify limit: Oper...
~
#htmlinsert(amazon_pc.html);
終了行:
* coreファイルの生成方法 [#d217e5aa]
現在の 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 以外にすれば良い。
#highlight(c){{
#include <stdio.h>
#include <stdint.h>
int main(void)
{
printf("%d\n", *(int *)0);
return 0;
}
}}
#highlight(end)
#ref(segv.tgz)
上記のテストコードでSEGVを発生させてみる。
$ 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) 7.12.0.20161007-git
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.o...
This is free software: you are free to change and redist...
There is NO WARRANTY, to the extent permitted by law. T...
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 on...
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "w...
Reading symbols from ./segv...(no debugging symbols foun...
[New LWP 2147]
Core was generated by `./segv'.
Program terminated with signal SIGSEGV, Segmentation fau...
#0 0x000055bcc1e696b9 in main ()
(gdb) q
$
なお、sshでログインした環境だと、2回目の実行に失敗するこ...
$ ulimit -c unlimited
-bash: ulimit: core file size: cannot modify limit: Oper...
~
#htmlinsert(amazon_pc.html);
ページ名: