How to generate a coredump file during program crash and debug it with GDB

Source: Internet
Author: User
How to generate coredump file and debug it in GDB

1. ulimit-A can view all current limit
2. ulimit-C is used to set coredump. For example: ulimit-C unlimited, the size of the generated coredump file is not limited. You can also use ulimit-C 1024 to set the coredump file size to not exceed 1 MB.
3. After the program crash is run, the core file is generated. At this point:

GDB <program> <corefile>

You can also directly run GDB and enter core <corefile> in the command line of GDB.

By default, GDB prints the function calls and causes for crash, such:

#0 0xb7ca729b in strlen () from/lib/tls/i686/cmov/libc. so.6

This indicates that the strlen function call has a problem.

Then run the BT command to print the function call Stack:

(GDB) BT
#0 0xb7ca729b in strlen () from/lib/tls/i686/cmov/libc. so.6
#1 0xb7e028ce in g_strdup () from/usr/lib/libglib-2.0.so.0
#2 0xb7fe1180 in ?? () From/usr/lib/libgobject-2.0.so.0
#3 0xb7fbed20 in g_object_set_valist () from/usr/lib/libgobject-2.0.so.0
#4 0xb7fbf266 in g_object_set () from/usr/lib/libgobject-2.0.so.0
#5 0x0804c889 in maid (Data = 0xbfdcd644) at tester. C: 1092
#6 0xb7e0c02f in ?? () From/usr/lib/libglib-2.0.so.0
#7 0xb7d9550f in start_thread () from/lib/tls/i686/cmov/libpthread. so.0
#8 0xb7d117ee in clone () from/lib/tls/i686/cmov/libc. so.6

This is clear, from the bottom up is the function call stack. The problem clearly lies in g_object_set. This function is called in the stst_pipeline_func function.

Therefore, using the core file is of great help to the debug program.

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.