debugging Coredump files using GDB

Source: Internet
Author: User

Turn from: http://blog.ddup.us/?p=176


Write A/C + + program often directly and memory to deal with, inadvertently will cause the execution of the program when the segment fault and hang out. In general this is due to the array of bounds access, null pointer or wild pointer read and write. program small words still better to do, to the source code carefully check can be resolved. But for a large number of code program, which contains n multiple function calls, n most groups of pointers to access, then want to locate the problem is not very easy (at this time the cattle can still be in the right place to play printf plus the way to find the two points quickly positioning: P). The lazy person's words or directly gdb get up. God horse is the core dump file

Occasionally can hear a programmer classmate complain "rub, again out core." ”。 In short, core dump is an action that the operating system performs, and when a process terminates unexpectedly (crash) for some reason, the operating system dumps the process's memory information (dump) to 1 on disk. The resulting file is the core file, which is usually named after the Core.xxx form. how to generate core Dump

Occurs doredump generally is when the process receives a signal, Linux now has more than 60 signals, you can use the Kill-l command all listed.

Sagi@sagi-laptop:~$Kill-L 1)Sighup 2)SIGINT 3)Sigquit 4)Sigill 5)Sigtrap 6)SIGABRT 7)Sigbus 8)SIGFPE 9)SIGKILL 10)SIGUSR1 11)SIGSEGV 12)SIGUSR2 13)Sigpipe 14)SIGALRM 15)Sigterm 16)Sigstkflt 17)SIGCHLD 18)Sigcont 19)SIGSTOP 20)SIGTSTP 21)Sigttin 22)Sigttou 23)Sigurg 24)SIGXCPU 25)Sigxfsz 26)SIGVTALRM 27)Sigprof 28)Sigwinch 29)Sigio 30)SIGPWR 31)Sigsys 34)Sigrtmin 35)Sigrtmin+1 36)Sigrtmin+2 37)Sigrtmin+3 38)Sigrtmin+4 39)Sigrtmin+5 40)Sigrtmin+6 41)Sigrtmin+7 42)Sigrtmin+8 43)Sigrtmin+9 44)SIGRTMIN+10 45)SIGRTMIN+11 46)SIGRTMIN+12 47)SIGRTMIN+13 48)SIGRTMIN+14 49)SIGRTMIN+15 50)SIGRTMAX-14 51)SIGRTMAX-13 52)SIGRTMAX-12 53)SIGRTMAX-11 54)SIGRTMAX-10 55)SIGRTMAX-9 56)SIGRTMAX-8 57)SIGRTMAX-7 58)SIGRTMAX-6 59)SIGRTMAX-5 60)SIGRTMAX-4 61)SIGRTMAX-3 62)SIGRTMAX-2 63)SIGRTMAX-1 64)Sigrtmax

For a specific signal, the application can write the corresponding signal processing function. If not specified, the default processing is taken, and the default processing is the Coredump signal as follows:

3)sigquit   4)Sigill    6)SIGABRT   8)SIGFPE     SIGSEGV    7)sigbus    sigsys5)
sigtrap    Sigxcpu  )sigxfsz  sigiot

We see SIGSEGV in which the general array crosses the line or accesses the null pointer to produce this signal. In addition, although the default is this, but you can also write your own signal processing function to change the default behavior, more signal related can see the reference link 33.

The above content is only the necessary condition to produce coredump, not sufficient condition. To generate the core file also depends on the program to run the shell, can be viewed through the ulimit-a command, the output is roughly as follows:

Sagi@ulimit -
    afilesize          (blocks,-c) 0
    size            (Kbytes, D) unlimited
    scheduling priority             (-e)
    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.