How to view error messages through GDB after a Linux program is down

Source: Internet
Author: User
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 turned off, can be viewed through ulimit-c if 0 is closed, we can open by Ulimit-c N, you are setting the Coredump file maximum KB, or directly set unlimited ulimit–c Unlimited2 after Setup we write an error program experiment//main.cppint Main () {int *XCJ = 0;*XCJ = 10;return 0;} 3 compile, remember to add-G debugging information into the program, and then run the program g++ MA In.cpp-o main-g

./main

4 using GDB to view debug information GDB main core

You can see the wrong information through GDB. More content can be searched online for "Xia Chaojun" to get my course or to see my video course at Csdn College http://edu.csdn.net/course/detail/3738

How to view error messages through GDB after a Linux program is down

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.