How to obtain a core file without restarting an application?
https://access.redhat.com/solutions/9952
- Red Hat Enterprise Linux
问题
- How to obtain a core file without restarting an application?
- How an application core can be generated when a process is not crashing?
- How to create an application core when process core size is set to 0?
决议
-
The
gcore
command can be used to obtain the core file without causing the application to abort using the following procedure:- Ensure that the
gdb
package is installed. - Run the application.
-
Execute the gcore command to generate a core file (like core.pid) from the application in the current directory:
$ gcore (pid of the process)
- Ensure that the
-
The core file will be outputted to the present working directory.
- Note :
- The
gcore
command runsgdb
and attaches to the process, causing the process to enterT
status. However, the process should try to continue to run after gdb finishes collecting a core. - One point to remember is that with
gcore
we can't get a coredump of a kernel process. Becausekernel
processes are immune to system call tracing,ptrace
which thegcore
command uses. When we issue agcore
to a pid, we are usingPTRACE_ATTACH
. When a parent process traces a child process, it usesPTRACE_TRACEME
. See the man page ofptrace
for more details.
- The