The process runs at a lower priority (this priority is different from the priority defined in the system, but refers to the priority of CPU code instructions) and is controlled by the operating system, so the operating system can stop the operation of a process without affecting other processes and save the relevant environment. This is the core dump file for analysis.
If the process is compiled in a high-level language and the user has a source program, you can bring a diagnostic symbol table (compilers in high-level languages have this function) to analyze which source program statement caused the problem, and add a core file through the analysis tool provided by the system, which makes it easier to correct the problem. Of course, unless you compile with a symbol table at the beginning, you can only recompile the program and rerun the program to reproduce the error.
If the user has no source program, he can only analyze the level of assembly instructions, and it is difficult to find problems and make corrections, so there is no need to bother and there is no way to find problems in this case.
When the process of kernel dump is in progress, the operating system will terminate the process abnormally and release the resources it occupies, which is unlikely to cause harm to the operation of the system itself. This is fundamentally different from system dump. When the system dump occurs, it is bound to be accompanied by system crash and shutdown. When dealing with the core dump, it will only cause the corresponding process to terminate, and the system itself will not crash. Of course, if this process is related to other processes, other processes will also be affected. As for the consequences, it depends on the handling mechanism of this abnormal situation (the process related to itself suddenly terminates), and there is no general conclusion.
How to generate a coredump file?
Log in to the LINUX server and enter it anywhere.
echo "ulimit -c 1024 " >& gt/etc/profile
Exit LINUX and log in to LINUX again.
Sign ulimit -c
If 1024 is displayed, it means that coredump has been opened.
// -
1 Introduction. Core storage file
// -
When a program crashes, it usually generates a core file in the specified directory. The core file is just a memory image (plus debugging information), which is mainly used for debugging.
// -
2. Turn on or off the generation of core files.
// -
Use the following command to prevent the system from generating core files:
Yulim -c 0
The following command can check whether the option to generate core files is turned on:
Yulimut -a
This command will display all user customizations, where the option -a stands for "All".
You can also modify system files to adjust core options.
In /etc/profile, there is usually a sentence prohibiting the generation of core files, and this setting is usually reasonable:
# There are no core files by default.
ulimit-S-c0 & gt; /dev/null 2 & gt; & amp 1
But sometimes in the development process, in order to debug the problem, it is still necessary to open the settings generated by the core file in a specific user environment.
Add ulimit -c unlimited to the user's ~/. Bash_profile allows specific users to generate core files.
If ulimit -c 0 also prohibits the generation of core files, but ulimit -c 1024 limits the size of the generated core files to 1024kb.
// -
3. Set the core dump file directory and naming rules.
// -
/proc/sys/kernel/core_uses_pid can control whether to add pid as extension in the file name of the generated core file. If added, the file content is 1, otherwise it is 0.
Proc/sys/kernel/core_pattern can set the storage location or file name of the formatted core file, for example, the original file content is core-%e.
It can be modified as follows:
echo "/corefile/core-% e-% p-% t " & gt; Core mode
Store the control generated core file in the /corefile directory, and the generated file name is core- command name -pid- timestamp.
The following is a list of parameters:
% p- insert pid into file name to add pid.
% u-insert current uid into filename adds the current uid.
% g-insert current GID into filename adds the current GID.
% s- Inserts the signal that causes the core dump into the file name and adds the signal that causes the core to generate.
% t- Insert the unix time occupied by the core dump into the file name and add the UNIX time when the core file is generated.
% h- Insert the host name where the core dump occurred into the file name add host name.
% e- Insert the name of the core dump executable file into the file name to add the command name.
// -
Using core files
// -
Type the directory where the core files are located:
Gdb -c core
It will start the debugger of GNU to debug the core file, and will display the name of the program that generated this core file, the signal to stop this program, and so on.
If you already know what program generated this core file, for example, MyServer crashed to generate core. 12345, then use the following instructions for debugging:
Gdb -c core MyServer
What should I do to learn the use of gdb?
// -
5. A small method to test the generated core file.
// -
Direct input instruction:
kill -s SIGSEGV $$