Unix 我如何找出导致内核转储的程序?

Unix 我如何找出导致内核转储的程序?,unix,osx-yosemite,pid,coredump,Unix,Osx Yosemite,Pid,Coredump,我用的是MacOSX10.10 我注意到我的硬盘已满,因为每隔几分钟就会在/cores中出现一个新的内核转储文件: $ ls -alhtr /cores total 3551488 -rw-r--r--@ 1 saqib admin 6.0K Apr 24 12:38 .DS_Store drwxr-xr-x 32 root admin 1.1K Aug 1 17:00 ../ -r-------- 1 saqib admin 578M Aug 1 22:36 c

我用的是MacOSX10.10

我注意到我的硬盘已满,因为每隔几分钟就会在
/cores
中出现一个新的内核转储文件:

$ ls -alhtr /cores
total 3551488
-rw-r--r--@  1 saqib  admin   6.0K Apr 24 12:38 .DS_Store
drwxr-xr-x  32 root   admin   1.1K Aug  1 17:00 ../
-r--------   1 saqib  admin   578M Aug  1 22:36 core.35049
-r--------   1 saqib  admin   578M Aug  1 22:37 core.35202
drwxrwxr-t@  6 root   admin   204B Aug  1 22:38 ./
-r--------   1 saqib  admin   578M Aug  1 22:38 core.35438
但我不知道哪些进程正在创建这些核心文件。文件名中的数字应该表示创建它们的进程的PID。当然,这些过程现在已经死了。那么,我怎样才能知道是哪个进程在创建这些核心,以便修复/删除它呢

编辑1

对核心文件执行
gdb-c
并不能提供我需要的信息:

$ gdb -c /cores/core.35438
GNU gdb (GDB) 7.8.1
Copyright (C) 2014 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-apple-darwin14.0.0".
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".
"/cores/core.35438": no core file handler recognizes format
(gdb)
编辑3

我使用名为的应用程序打开了核心文件。你可以看到它显示给我的截图。我仍然不知道是哪个应用程序创建了这个核心文件


如果系统安装了
gdb
,则可以使用
gdb-c..
命令:

gdb -c core.35049
您将获得如下输出:

GNU gdb (Ubuntu 7.9-1ubuntu1) 7.9
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 "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".
[New LWP 2905]
Core was generated by `./a.out'.
Program terminated with signal SIGSEGV, Segmentation fault.

运行控制台实用程序,可在/Applications/Utilities中找到。在“诊断和使用信息”下查看用户诊断报告和系统诊断报告。每个最近的崩溃都应该有一个条目,其中包括程序名、日期、时间和主机名。您可以单击其中的每一个以获取更多信息


您也可以直接在文件系统中访问诊断报告。用户诊断报告位于~/Library/Logs/DiagnosticReports/中,系统诊断报告位于/Library/Logs/DiagnosticReports/

我只需要在OS X 10.13上执行此操作,并且在lldb中使用
图像列表
命令对我有效

lldb -c /cores/core.45943
(lldb) target create "/cores/core.45943"
Core file '/cores/core.45943' (i386) was loaded
(lldb) image list

不幸的是,
gdb-c
不起作用。我对原始帖子进行了编辑,以说明原因。还有什么想法吗?@SaqibAli,关于
文件/cores/core.35438
?@SaqibAli,对不起,我没有想法。没有直接关系,但你看过吗?默认情况下应该启用它并记录所有崩溃,但您可能希望将其设置为开发人员模式,如Run a little loop(运行一个每秒将所有进程ID存储到一个文件中的小循环),然后等待核心到达,使用Ctrl-C停止循环,并检查文件中的进程ID<代码>while:;do ps-aef>>/tmp/pids.txt;睡眠1;完成我可以grep这个控制台文件吗?怎么做?当然,你可以用grep。我已经在答案中添加了目录名。这是我从macOS内核获取信息的唯一方法。
$ file core
core: ELF 64-bit LSB core file x86-64, version 1 (SYSV), SVR4-style, from './a.out'
lldb -c /cores/core.45943
(lldb) target create "/cores/core.45943"
Core file '/cores/core.45943' (i386) was loaded
(lldb) image list