Answers:
...您通常什么也找不到。但是幸运的是,Linux为此提供了一个处理程序,您可以在运行时指定该处理程序。在/usr/src/linux/Documentation/sysctl/kernel.txt中,您将找到:
[/ proc / sys / kernel /] core_pattern用于指定核心转储文件模式名称。
- 如果模式的第一个字符是'|',则内核会将模式的其余部分视为要运行的命令。核心转储将被写入该程序的标准输入,而不是文件。
(谢谢)
根据消息来源,这是由abrt
程序处理的(即自动Bug报告工具,不会中止),但是在我的Arch Linux上,它是由systemd处理的。您可能需要编写自己的处理程序或使用当前目录。
现在它包含的内容是特定于系统的,但是根据所有已知的百科全书:
[核心转储]由计算机程序在特定时间的工作存储器的记录状态组成。实际上,通常会同时转储程序状态的其他关键部分,包括处理器寄存器,这些寄存器可能包括程序计数器和堆栈指针,内存管理信息以及其他处理器和操作系统标志和信息。
...因此它基本上包含了所有gdb
想要的东西,以及更多。
两者都会很高兴,因为gdb
只要您拥有可执行文件的精确副本,它就会加载任何核心转储gdb path/to/binary my/core.dump
。然后,您应该能够像往常一样继续开展业务,并因尝试并未能修复错误而不是尝试并未能再现错误而烦恼。
通常会调用核心文件,该文件core
位于进程的当前工作目录中。但是,有很多原因导致无法生成核心文件,并且它可能完全以其他名称位于其他位置。有关详细信息,请参见core.5手册页:
描述
某些信号的默认操作是使进程终止并产生一个核心转储文件,该文件是一个磁盘文件,包含终止时进程内存的映像。该映像可以在调试器(例如gdb(1))中使用,以在程序终止时检查程序的状态。 导致进程转储内核的信号列表可以在signal(7)中找到。
...
在多种情况下不会生成核心转储文件:
* The process does not have permission to write the core file. (By default, the core file is called core or core.pid, where pid is the ID of the process that dumped core, and is created in the current working directory. See below for details on naming.) Writing the core file will fail if the directory in which it is to be created is nonwritable, or if a file with the same name exists and is not writable or is not a regular file (e.g., it is a directory or a symbolic link). * A (writable, regular) file with the same name as would be used for the core dump already exists, but there is more than one hard link to that file. * The filesystem where the core dump file would be created is full; or has run out of inodes; or is mounted read-only; or the user has reached their quota for the filesystem. * The directory in which the core dump file is to be created does not exist. * The RLIMIT_CORE (core file size) or RLIMIT_FSIZE (file size) resource limits for the process are set to zero; see getrlimit(2) and the documentation of the shell's ulimit command (limit in csh(1)). * The binary being executed by the process does not have read permission enabled. * The process is executing a set-user-ID (set-group-ID) program that is owned by a user (group) other than the real user (group) ID of the process, or the process is executing a program that has file capabilities (see capabilities(7)). (However, see the description of the prctl(2) PR_SET_DUMPABLE operation, and the description of the /proc/sys/fs/suid_dumpable file in proc(5).) * (Since Linux 3.7) The kernel was configured without the CONFIG_COREDUMP option.
此外,如果使用了madvise(2)MADV_DONTDUMP标志,则核心转储可能会排除进程的部分地址空间。
核心转储文件的命名
默认情况下,核心转储文件名为core,但是/ proc / sys / kernel / core_pattern文件(自Linux 2.6和2.4.21起)可以设置为定义用于命名核心转储文件的模板。模板可以包含%说明符,在创建核心文件时,这些说明符将由以下值替换:
%% a single % character %c core file size soft resource limit of crashing process (since Linux 2.6.24) %d dump mode—same as value returned by prctl(2) PR_GET_DUMPABLE (since Linux 3.7) %e executable filename (without path prefix) %E pathname of executable, with slashes ('/') replaced by exclamation marks ('!') (since Linux 3.0). %g (numeric) real GID of dumped process %h hostname (same as nodename returned by uname(2)) %i TID of thread that triggered core dump, as seen in the PID namespace in which the thread resides (since Linux 3.18) %I TID of thread that triggered core dump, as seen in the initial PID namespace (since Linux 3.18) %p PID of dumped process, as seen in the PID namespace in which the process resides %P PID of dumped process, as seen in the initial PID namespace (since Linux 3.12) %s number of signal causing dump %t time of dump, expressed as seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC) %u (numeric) real UID of dumped process
gdb path-to-your-binary path-to-corefile
,然后info stack
是Ctrl-d
。唯一令人担心的是,核心转储对您来说是很平常的事情。