[linux] coredump, gdb debugging crash program

1. What is coredump?

When the program terminates abnormally or crashes during the running process, the operating system will record the memory status of the program at that time and save it in a file (core file). This behavior is called Core Dump or 'core dump'. Using coredump It can help us quickly locate the location of the program crash.
The difference between coredump and Valgrind

Valgrind作用性体现更多在于“内存泄露”的检查
coredump可以捕捉因为空指针、野指针的访问,会引发程序段错误(segment fault )

2. Start coredump

The size of the file (core file) recorded by the system to record the core dump is 0 by default, that is, the coredump function is turned off by default. If you want to start the coredump function, just set the size of the core file. For example, use ulimit -a to view various size limits, where the core file size is the size of the coredump, and the unit is blocks, as shown below:

$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d

Guess you like

Origin blog.csdn.net/u010168781/article/details/129746816