This document is excerpted from the network and its own processing and sorting.
<! --
@ Page {size: 8.5in 11in; margin: 0.79in}
P {margin-bottom: 0.08in}
-->
Linux core dump configuration and debugging
1. Core File generation switch and size limit
---------------------------------
1) Use
Ulimit
-C command to view
Core File generation switch. If the result is
0 indicates that this function is disabled and will not be generated
Core File.
2)
Use
Ulimit
-Cfilesize command, which can be restricted
Core File size (
The filesize unit is
Kbyte ). If
Ulimit
-Cunlimited, indicates
The core file size is unrestricted. If the generated information exceeds this size, it will be cropped to generate an incomplete
Core File. Debug this
Core files,
GDB will prompt an error.
2. Name and path of the Core File
----------------------------
If
The core file is named
Core. New
Core File generation will overwrite the original
Core File.
1)
/Proc/sys/kernel/core_uses_pid can be controlled
Whether to add the core file to the file name
PID as an extension. The file content is
1, indicating to add
PID is generated as the extension
The core file format is
Core. xxxx; is
0 indicates the generated
The same core file is named
Core.
Run the following command to modify the file:
Echo
"1">
/Proc/sys/kernel/core_uses_pid
2)
Proc/sys/kernel/core_pattern can be controlled
Core File storage location and file name format.
Run the following command to modify the file:
Echo
"/Corefile/Core-% E-% P-% t">
Core_pattern, which can be set
Core files are uniformly generated
/Corefile directory, the generated file name is
Core-command name
-PID-Timestamp
The following is a list of parameters.
:
% P-insert PID into filename add
PID
% U-insert current uid into filename add current
UID
% G-insert current GID into filename add current
GID
% S-insert signal that caused the coredump into the filename
Add to generate
Core Signal
% T-insert UNIX time that the coredump occurred into filename
Add
When the core file is generated
UNIX time
% H-insert hostname where the coredump happened into filename
Add Host Name
% E-insert coredumping executable name into filename
Add command name
3. Use
View GDB
Core File
:
Below we can occur when an error occurs due to the running letter
Core
Dump
.
Occurred
Core
After dump
, Use
View through GDB
Core File Content
,
To locate the file
Core
Dump row
.
GDB [exec file] [Core
File]
For example
:
GDB./test
Test. Core
Before entering
After GDB
,
Use
View BT commands
Backtrace to check where the program is running
,
To locate
Core Dump File
-> Line
.
4. Use on the Development Board
Core File debugging
-----------------------------
If the operating system of the Development Board is
Linux,
The core debugging method is still applicable. If not
GDB, which can include the Development Board environment (header files, libraries), executable files, and
Copy core files
PC
In Linux, run related commands.
Note: The executable files to be debugged must be added during compilation.
-G,
The core file can display error information normally!
Notes:
In
In Linux, ensure that the program is generated when the program crashes.
Pay attention to these issues in coredump:
1. Ensure Storage
The coredump directory exists and the process
The directory has the write permission. Storage
The coredump directory is the current directory of the process, which is generally the directory where the command was issued to start the process. However, if it is started through a script, the script may modify the current object
The current directory of the process is different from the directory where the script was originally executed. In this case, you can view"
/Proc/<Process
PID>/CWD "specifies the target of the symbolic link to determine the process
The actual current directory address. You can also view the processes started by the system service in this way.
2. If the program calls
Seteuid ()/setegid () Change
By default, the system does not generate
Coredump. Many service programs call
Seteuid (), such
MySQL, no matter what you use
User operation
Start mysqld_safe
MySQL,
Valid users of mysqld are always
Msyql user. If you use a user
A runs a program,
PS.
The user of this program is
B, then these processes are called.
Seteuid. To enable these processes to generate
Core
Dump.
/Proc/sys/fs
The content of the/suid_dumpable file is changed
1 (the default value is
0 ).
3. This is generally known as setting large enough
Core File Size Limit
. Generated when the program crashes
The core file size is the memory size occupied by the program running. However, when a program crashes, the behavior cannot be estimated as usual. For example, errors such as buffer overflow may cause the stack to be
Damage, so the value of a variable is often changed to a mess, and then the program uses this size to apply for memory may cause the program to occupy more memory than usual. Therefore
To ensure the generation of memory
Set the core file size
Unlimited is better.