GDB Debug Core file

Source: Internet
Author: User

About core Files

Linux programs may run into a crash during operation, at which point the core file can be recorded on the scene of the program, to facilitate the subsequent search for problems.


Preparatory work

    • Enable Core file
      By default, the core file is not enabled, that is, the program will not generate a crash core file, so you need to turn on this feature
    • View Core file status
      Ulimit-a
      If the core file size behavior is 0, then the core files are not enabled and need to be executed
      Ulimit-c 2048
      To reset the upper limit of the core file size, you can customize the maximum file size value.
    • Set the core file name and save address
      sudo echo "./core.%p" >/proc/sys/kernel/core_pattern
      The above command indicates that a crash file was generated in the current directory with the process ID of the file. There are other optional parameters:
      %p-insert pid into Filename%u-insert current uid to filename%g-insert current GID into filename%s-insert signal That caused, the coredump into the Filename%t-insert UNIX time, the coredump occurred into Filename%h-insert hostn Ame where the coredump happened into Filename%e-insert coredumping executable name into filename

Using the core file

Following the previous setup, when the program crashes, the core file is generated in the directory where the program is located. At this point, we can use GDB to open the core file

GDB Program Name core file
In general, the program navigates directly to the location where the program went wrong, and if not, you can use the where order to locate it.

It is important to note that the program compiles with the parameter option-G, which makes enough debugging information.

GDB Debug Core file

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.