How to generate core dump for an application in Linux
In order to troubleshoot application issue, a process content in memory can be dumped to a file and then the file can be analysed with debug tool, such as gdb in Linux.
Another way of doing this is to send QUIT signal to the PID (kill –3 PID), but the thread dump will be directed to stdout, which can be viewed with “cat /proc/PID/fd/1 |tee /tmp/dump.log”, messages will be constantly directed to /proc/PID/fd/1 until the process is stopped. So it is useful for real time debugging.
The following java application example use gcore command in gdb. (gcore or kill –3 will not stop the process )
Linux default core file size is 0, which means core dump is disabled, It needs to be changed to unlimited
努力做一个优秀的搬运工,附上链接是必要的,要翻译请尽管开口。
http://honglus.blogspot.com/2010/06/how-to-generate-thread-dump-for.html
How to generate core dump for an application in Linux
In order to troubleshoot application issue, a process content in memory can be dumped to a file and then the file can be analysed with debug tool, such as gdb in Linux.
Another way of doing this is to send QUIT signal to the PID (kill –3 PID), but the thread dump will be directed to stdout, which can be viewed with “cat /proc/PID/fd/1 |tee /tmp/dump.log”, messages will be constantly directed to /proc/PID/fd/1 until the process is stopped. So it is useful for real time debugging.
The following java application example use gcore command in gdb. (gcore or kill –3 will not stop the process )
Linux default core file size is 0, which means core dump is disabled, It needs to be changed to unlimited
Firstly, find the virtual memory size of the process, the PID is 10008 in following example.
The process VSZ=2.2GB, it will be the size of the core file. Go to a dump dir which has more than 2.2GB free space
$cd /var/tmp
Attach to running process PID.
$gdb --pid=10008
At the gdb prompt, enter gcore command
gdb>gcore
wait for few minutes for core file to be generated. type in quit to exit gdb, answer yes to detach the process.
gdb>quit
core file is generated
file command reveals the source program name