【发布时间】:2017-06-29 03:30:50
【问题描述】:
我的系统中生成了一些核心文件,但是这些核心文件的后缀只有时间戳,没有进程ID信息。
那么核心文件中是否有任何与进程 ID 相关的信息,以便我可以通过 gdb 或其他工具了解它?
【问题讨论】:
标签: c++ linux process gdb core
我的系统中生成了一些核心文件,但是这些核心文件的后缀只有时间戳,没有进程ID信息。
那么核心文件中是否有任何与进程 ID 相关的信息,以便我可以通过 gdb 或其他工具了解它?
【问题讨论】:
标签: c++ linux process gdb core
所以核心文件中有任何与进程 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`
是的,使用“文件”命令。
file <core_file>
这应该告诉您是什么可执行文件/命令导致核心转储。如果这不是您需要的,请告诉我。
【讨论】: