When we write the service-side program, because of multi-threaded and complex environment, the program may be in the case of uncertain conditions of the outage, not good again, this is how we get the program error message, a method by logging, sometimes some error logs can not be reflected, then use our core Dump file.
Typically, COREDMP contains memory, register status, stack pointers, memory management information, and so on when the program runs. It can be understood that the current state of the program's work is stored as a file. Many programs and operating systems automatically generate a core file when errors occur.
1 Our system is generally the default is the core dump is turned off, can be viewed through ulimit-c if 0 is closed, we can open by Ulimit-c N, you are setting the maximum value of Coredump file KB, or directly set unlimited
Ulimit–c Unlimited
2 after Setup, we'll write an error-prone program to experiment.
Main.cpp
int main () {int *XCJ = 0; *XCJ = 10; return 0;}
3 Compile, remember add-G debugging information into the execution program, and then run the program
g++ Main.cpp-o main-g
./main
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M02/8E/29/wKiom1i3hi-RTvKSAABFH9HWiEQ293.png-wh_500x0-wm_ 3-wmp_4-s_1973401201.png "style=" Float:none; "title=" 222.png "alt=" Wkiom1i3hi-rtvksaabfh9hwieq293.png-wh_50 "/>
4 using GDB to view debug information
GDB Main Core
650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M02/8E/29/wKiom1i3hjKi-IThAAF2M24FXNM920.png-wh_500x0-wm_ 3-wmp_4-s_1168453441.png "style=" Float:none; "title=" 111.png "alt=" Wkiom1i3hjki-ithaaf2m24fxnm920.png-wh_50 "/>
You can see the wrong information through GDB.
More content can search online "Xia Chaojun" to get my course
Can watch my video tutorial at 51cto College
0 Basic learning to compile and debug C + + Project video courses on Linux
Http://edu.51cto.com/course/course_id-8237.html
650) this.width=650; "Src=" Https://s1.51cto.com/images/201701/699a96c6825e14d0199454e7e41289cc6e37ff_middle.png " Width= "221" height= "166" alt= "699a96c6825e14d0199454e7e41289cc6e37ff_m"/>
This article from "Xia Chaojun" blog, declined reprint!
How to view error messages through GDB after a Linux program is down