簡單修改core的後綴名及路徑



 echo "/tmp/core-%e-%p" > /proc/sys/kernel/core_pattern

本會話生成的core文件將以  "/tmp/core-程序名-進程號"    的形式生成


使進程產生core(另外一個shell會話)

root@ubuntu:~# 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
root@ubuntu:~# kill -6 16630




 ./a.out 
Aborted (core dumped)


root@ubuntu:/share# cd /tmp/
root@ubuntu:/tmp# ls
config-err-D1f0Pj                                                                  ubuntu-release-upgrader-s6d8wtgs
core-a.out-16630         




root@ubuntu:/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) 



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章