简单修改core的后缀名及路径
echo "/tmp/core-%e-%p" > /proc/sys/kernel/core_pattern
本会话生成的core文件将以 "/tmp/core-程序名-进程号" 的形式生成
使进程产生core(另外一个shell会话)
[email protected]:~# ps -aux| grep a.out
root 16630 47.7 0.1 43320 732 pts/4 Sl+ 00:26 0:01 ./a.out
root 16637 0.0 0.3 4540 1936 pts/6 S+ 00:26 0:00 grep --color=auto a.out
[email protected]:~# kill -6 16630
./a.out
Aborted (core dumped)
[email protected]:/share# cd /tmp/
[email protected]:/tmp# ls
config-err-D1f0Pj ubuntu-release-upgrader-s6d8wtgs
core-a.out-16630
[email protected]:/share# gdb a.out /tmp/core-a.out-16630
GNU gdb (Ubuntu 7.10-1ubuntu2) 7.10
Copyright (C) 2015 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 "i686-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 a.out...done.
[New LWP 16630]
[New LWP 16631]
[New LWP 16632]
[New LWP 16633]
[New LWP 16634]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
Core was generated by `./a.out'.
Program terminated with signal SIGABRT, Aborted.
#0 0xb770abe8 in __kernel_vsyscall ()
[Current thread is 1 (Thread 0xb7516700 (LWP 16630))]
(gdb)
(gdb)
(gdb)
(gdb) info threads
Id Target Id Frame
5 Thread 0xb5d12b40 (LWP 16634) 0xb770abe8 in __kernel_vsyscall ()
4 Thread 0xb6513b40 (LWP 16633) 0xb770abe8 in __kernel_vsyscall ()
3 Thread 0xb6d14b40 (LWP 16632) 0xb770abe8 in __kernel_vsyscall ()
2 Thread 0xb7515b40 (LWP 16631) 0xb770abe8 in __kernel_vsyscall ()
* 1 Thread 0xb7516700 (LWP 16630) 0xb770abe8 in __kernel_vsyscall ()
(gdb)