What is core dump
Core dump is also called the kernel dump, when the program runs the exception, when the program exits unexpectedly, the operating system to the program's current memory state stored in a core file, called Core dump. Core dump is helpful in diagnosing the problem after the application has been crash off. The core dump is off when it is installed by default.
How to see if the system has core dump turned on
Use "ulimit-c" to see if the core dump is open. If the result is 0, this feature is turned off and the core file is not generated
How to open core dump
Method One: The command line mode "Ulimit-c 1024", in this example opened the core dump and limit the file size of 1024k, now the program occupies a fierce memory, the previous write C program needs to calculate the memory of the era has passed. If there is no limit, maybe a core file, a few G went out ~, of course there is no restriction of the way there are "Ulimit-c unlimited"
Method Two: Configure the profile file, open the/etc/profile file, inside can find "Ulimit-s-C 0 >/dev/null 2>&1", change it to "ulimit-s-C unlimited >/dev /null 2>&1 "
Method Three: Modify the/etc/security/limits.conf file, add "* Soft core 0", this method can open core dump "user soft core 0 or @group soft core 0" for the specified user or user group. However, it is important to use this method to comment out the line mentioned in method two, and not to exist simultaneously.
How to view the save path and file name format for a core file
By default, when the core is turned on, if the app occurs crash, a core is generated in the app's location. "Apply pid" file, filename is not very readable, management is not convenient.
View the path and format of the core file you are using "More/proc/sys/kernel/core_pattern"
The configuration of the auto-add PID is configured in "More/proc/sys/kernel/core_uses_pid", if 1 is automatically added
How to modify the save path and file name format for a core file
Modify the/etc/sysctl.conf file "vi/etc/sysctl.conf", add the path you want to save "Kernel.core_pattern =/tmp/corefile/core.%e.%t", It is important to note that the path must have write permissions applied, or the core file will not be generated. Then execute the command "sysctl-p" to take effect. About core_users_pid Default in the Sysctl file already exists, do not need to change, PID is very important information.
Attach a list of formats supported by the core file:
%p–insert pid into filename "pid"
%u–insert current UID into filename "UID"
%g–insert current GID into filename "gid"
%s–insert signal that caused the coredump into the filename "core signal"
%t–insert Unix time that the coredump occurred to filename "core file when it was generated"
%h–insert hostname where the coredump happened into filename "host name"
%e–insert coredumping executable name into filename "app names"
How to use the core generated by the test program
[C-sharp]View PlainCopy
- #include <iostream>using namespace Std;int main () {* (char *) 1=1; return 0;}
Turn from
Linux system opens the configuration of core dump and throws CORE-CSDN blog with shortest program
6577604
Linux system opens the configuration "go" of core dump