gdb调用程序崩溃时的内存镜像core文件

/*
 * gcc gdb_test.c -o gdb_test -g
 * ./gdb_test 
 * Segmentation fault (core dumped)
 * gdb gdb_test -c core.5521 
 * Core was generated by `gdb_test'.
 * Program terminated with signal 11, Segmentation fault.
 * #0  0x000000000040048b in main (argc=1, argv=0x7fff00c0b438) at gdb_test.c:18
 * 18		*ptr='\n';
 */
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>

int main(const int argc,const char *argv[])
{
	char *ptr=NULL;
	*ptr='\n';
	return 0;
}
/*
 * add follow in the ~/.bashrc file to generate core file
 * ulimit -c unlimited
 */

你可能感兴趣的:(gdb调用程序崩溃时的内存镜像core文件)