linux the core file generation, path, formatting and debugging

and generating a debug core file
1 Code
#include <stdio.h>
int main ()
{
int * P = NULL;
* P = 0;
return 0;
}

2 executed in the current shell ulimit -c unlimited
Note: This command only take effect in the current shell, another shell will fail ulimit -c 0, to generate core files failed.

3 is provided and the core file format generation path, the current execution of the program in the default directory, the following two commands:
echo ". 1"> / proc / SYS / Kernel / core_uses_pid
echo "/ CoreFile / p-core-%%% E- t "> / proc / sys / kernel / core_pattern

The core unified file generation to the next / corefile directory, file name is core- command name -pid- timestamp
Note: / corefile need to create the directory.

The following is a list of parameters:
% the p-- INSERT pid INTO filename added pid (process of the above mentioned id)
% U - INSERT Current uid INTO filename add the current uid (user the above mentioned id)
% G - INSERT Current gid INTO filename add the current gid (user group the above mentioned id)
% s - insert signal that caused the coredump into the filename was added resulting in core signal
% t - unix time when insert UNIX time that the coredump occurred into filename added core file generating
% h - insert hostname where the coredump happened into filename Add host name
% e - insert coredumping executable name into filename to add lead to core command name

4 generation and debugging core files
gcc -o the Test test.c
./test
Segmentation Fault (core dumped)
paragraph mistakes here and generate core files

Found in / corefile directory core-test-31421-1476266571
start debugging
gdb ./test core-test-31421-1476266571

Guess you like

Origin www.cnblogs.com/wangjian8888/p/11978397.html