【问题标题】:linux: is there a way to find out which process generated a core file?linux:有没有办法找出哪个进程生成了核心文件?
【发布时间】:2017-06-29 03:30:50
【问题描述】:

我的系统中生成了一些核心文件,但是这些核心文件的后缀只有时间戳,没有进程ID信息。

那么核心文件中是否有任何与进程 ID 相关的信息,以便我可以通过 gdb 或其他工具了解它?

【问题讨论】:

标签: c++ linux process gdb core


【解决方案1】:

所以核心文件中有任何与进程 ID 相关的信息

肯定的。

core 文件中,有一组ELF 注释。您要查找的便笺类型为 NT_PRPSINFO,它包含(除其他外)您想要的 pr_pid

typedef struct prpsinfo {       /* Information about process                 */
  unsigned char  pr_state;      /* Numeric process state                     */
  char           pr_sname;      /* Char for pr_state                         */
  unsigned char  pr_zomb;       /* Zombie                                    */
  signed char    pr_nice;       /* Nice val                                  */
  unsigned long  pr_flag;       /* Flags                                     */
  uint32_t       pr_uid;        /* User ID                                   */
  uint32_t       pr_gid;        /* Group ID                                  */

  pid_t          pr_pid;        /* Process ID                                */
  pid_t          pr_ppid;       /* Parent's process ID                       */
  pid_t          pr_pgrp;       /* Group ID                                  */
  pid_t          pr_sid;        /* Session ID                                */
  char           pr_fname[16];  /* Filename of executable                    */
  char           pr_psargs[80]; /* Initial part of arg list                  */

} prpsinfo;

问题是:哪些工具可以找到并解码此笔记。从elfutils 尝试eu-readelf

【讨论】:

  • 这正是我所需要的,我做了一个eu-readelf --all core.11234,然后几行我得到了:` CORE 136 PRPSINFO state: 0, sname: R, zomb: 0, nice: 4, flag : 0x0000000000402440 uid: 5000, gid: 492600, pid: 11869, ppid: 11804, pgrp: 11487`
【解决方案2】:

是的,使用“文件”命令。

file <core_file>

这应该告诉您是什么可执行文件/命令导致核心转储。如果这不是您需要的,请告诉我。

【讨论】:

  • 问题是关于process id,这个答案没有回答。
  • 有人将此问题标记为可能重复。如果你去其他问题,你会发现它基本上与我给出的答案相同。我不是唯一一个以这种方式解释这个问题的人。
猜你喜欢
  • 2015-07-24
  • 1970-01-01
  • 2018-12-16
  • 2012-02-01
  • 2014-07-20
  • 1970-01-01
  • 2012-10-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多