Linux system generation and commissioning Coredump files

Source: Internet
Author: User
Tags terminates

When the system is configured with Coredump, the operating system produces a core file in the specified directory in the file name format when the program terminates abnormally. The core file is a program memory image and related debugging information, debugging the Coredump file through gdb to know the cause of the program's abnormal termination.

1. System Configuration Coredump

The first is to open the Coredump, through the ulimit command to see if Coredump open:

[Email protected] coredump]# Ulimit-AcorefileSize (blocks,-c) Unlimiteddata seg size (Kbytes,-d) unlimitedscheduling priority (-e)0fileSize (blocks,-f) unlimitedpending signals (-I.)7903Max locked Memory (Kbytes,-L) -max memory Size (Kbytes,-m) unlimitedopen files (-N)1024x768Pipe Size ( +Bytes,-p)8POSIX message queues (bytes,-Q)819200Real- TimePriority (-R)0stack size (Kbytes,-s)8192CPU Time(Seconds,-t) Unlimitedmax user processes (-u)7903virtual Memory (Kbytes,-v) UnlimitedfileLocks (-X) Unlimited

The value of the core file size configuration entry is unlimited, which indicates that Coredump is open and does not limit the size of the core files. If the core file size configuration item has a value of 0 indicating that Coredump is not open, you can pass the command:

Ulimit-c Unlimited

To open the system's coredump.

Specify the path to the core file and the file name format of the core file:

Echo " 1 " >/proc/sys/kernel/core_uses_pid

The Core_uses_pid file can control whether the resulting core file has PID, set Core_uses_pid to 1 so that the resulting core file with the PID of the corresponding process as the end of the file.

Echo " /corefile/core-%e-%p-%t " >/proc/sys/kernel/core_pattern

Core_pattern controls the file name format of the core file and the resulting path of the core file, which causes the system to generate the core file in the/corefile directory, The file name format of the core file is similar to core-test-17129-1402996666 (core-executable name-process PID number-generation time).

2, an example of generating coredump files

The following program will cause a fragment error due to illegal memory access, causing the program to terminate abnormally, the system automatically generates a core file.

#include <stdio.h><stdlib.h>void  Test () {    char'  ABC";     ' x ' ;} int Main (intChar* * argv) {    test ()    ; return (exit_success);}

When the program is compiled and executed, the program terminates abnormally and produces a core file:

[Email protected] coredump]#/testsegmentation fault (core dumped)

3, gdb debug Coredump file, determine the cause of abnormal termination of the program

To the/corefile directory to find the core file that was generated by the program, GDB debugs the core file:

[Email protected] coredump]# GDB test/corefile/core-test-17525-1403006130GNU gdb (gdb) Red Hat Enterprise Linux (7.2- -. El6) Copyright (C) .Free software Foundation, Inc.license GPLv3+: GNU GPL version3or later //gnu.org/licenses/gpl.html>This is FreeSoftware:you is FreeTo change and redistribute it.  There is NO WARRANTY, to the extent permitted by law. Type"Show Copying" and"Show Warranty"  fordetails. This GDB is configured as"X86_64-redhat-linux-gnu". For bugs reporting instructions, please see://Www.gnu.org/software/gdb/bugs/>, .....Reading symbols From/home/coredump/test ... Done. [New Thread17525]missing separate Debuginfo forTry:Yum--disablerepo='*'--enablerepo='*-debug*' Install/usr/lib/debug/.build-ID/ -/19e7405069cf9fce3e07d2cc9f284ed6e5c40freading symbols from/lib64/libc.so.6... (No debugging symbols found) ... Done. Loaded symbols for/lib64/libc.so.6Reading symbols from/lib64/LD-linux-x86- -. So.2... (No debugging symbols found) ... Done. Loaded symbols for/lib64/LD-linux-x86- -. So.2Core is generated by './test'.Program terminated with Signal One, segmentation fault.#0  0x0000000000400484 inchTest () at test.c:77*s ='x'; Missing separate Debuginfos, Use:debuginfo-Installglibc-2.12-1.107. el6.x86_64 (GDB)

As can be seen from the information above, the reason for the program to terminate abnormally is that a segment error has occurred and can be specifically targeted to the program statement that caused the segment error.

Above is simple coredump function of use method, Play happy!!!

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.