During the development process, when a Linux program exits abnormally, we can analyze the details of its exception through the core file. By default, Linux does not produce a core file when the program is abnormal, and to produce a core dump file when the program exits unexpectedly, you need to use the ulimit command to change the settings of the Coredump:
The above command indicates that the core dump file is generated when the program is abnormal and does not limit the size of the core dump file.
core. Obviously, if there are multiple programs that produce a core file, or if the same program crashes multiple times, the same core file is overwritten repeatedly.
By modifying the parameters of the kernel, we can specify the file name of the Coredump file generated by the kernel. For example, Easwy uses the following command to enable kernel to generate a core dump file in the name Core.filename.pid format:
%e and %p will be replaced with the program file name and process ID.
There are many more variables that can be used in the Core_pattern template, see the following list:
- Percent of a single% character
- Process ID of the%p dump process
- The actual user ID of the%u dump process
- %g The actual group ID of the dump process
- %s causes the signal for this core dump
- %t Core Dump time (number of seconds from January 1, 1970)
- %H Host Name
- %e program file name
If you include the directory separator "/", the resulting core file will be placed in the specified directory.
It is necessary to note that there is also a coredump-related setting in the kernel, which is /proc/sys/kernel/core_uses_pid. If the content of this file is configured to 1, the final generated core dump file name will still be added to the process ID even if%p is not set in Core_pattern.
For the resulting core dump process analysis, you need to use debugging tools, such as GDB. See other articles in Easwy.
This article link address: http://easwy.com/blog/archives/customize-filename-of-core-dump/
Linux usage notes: Customizing the file name of the core dump file