Debugging technology of Linux core dump

Source: Internet
Author: User

Some programs can be compiled, but the Segment fault (Segment error) will occur during running ). this is usually caused by pointer errors. the following is a detailed introduction to the debugging technology of Linux core dump.


1. Linux core dump:
Some programs can be compiled, but Segment fault (Segment error) may occur during runtime. This is usually caused by pointer errors.
However, this does not prompt the file-> line like a compilation error, but does not have any information, making debugging difficult.


2. Linux core dumpgdb:
One way is to use gdb step for further search.
It is feasible to put it in short code, but to let you step into a code of tens of thousands of lines, I think you will hate the programmer name and call it a programmer.
We still have a better solution, which is core file.


3. Linux core dumpulimit:
If you want the system to generate a core file when an error occurs due to signal interruption, you need to set it in shell as follows:
# Set the core size to unlimited
Ulimit-c unlimited
# Set the file size to unlimited
Ulimit unlimited


These require the root permission. In ubuntu, you need to re-enter the first command to set the core size to infinite.


4. Use gdb to view the core file in Linux core dump:
Here we can dump the core when an error occurs due to the message number.
After a core dump occurs, use gdb to view the content of the core file to locate the line that causes the core dump in the file.
Gdb [exec file] [core file]
For example:
Gdb./test. core
After entering gdb, run the bt command to check where the program is running and locate the core dump file-> line.


5. How can we avoid the appearance of core files?
If tcsh is used, add a line in. tcshrc as follows:
Limit coredumpsize 0
If bash is used, add (or modify) one in/etc/profile:
Ulimit-c 0

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.