Three ways to build the core and debug GDB using the core

Source: Internet
Author: User

If you can run the program repeatedly, then we can easily use the following methods to run the program repeatedly started GDB debugging:

$gdb

(gdb) file./a.out

(GDB) Run


If the problematic program cannot be run repeatedly, but there is a core file that cannot begin GDB debugging with the process above, you can use the core file for GDB debugging as follows:

Core dump: The state at which the save problem occurred

$ulimit-C

$ulimit-C Unlimited

$file core.*

$gdb-C core.7561/a.out #core. 7561 when a.out Core dump, gdb-c import core to debug A.out program

(GDB) List 5 #开始进行gdb调试对a. Out


Note:

1) Ulimit is a resource-related command

It is a useful command to see the maximum stack-size of a process, the maximum core-size, and the maximum number of FD files that can be opened at the same time.

$ulimit-A To view the maximum limit values for various resources.

You can also modify the maximum limit values for each of these resources using Ulimit.

2) How to create a core?

Method 1) Do not terminate the program to generate its core

$gcore #进程号为1920

$gcore ' pidof/a.out ' #进程名为./a.out

Method 2) GdB debugs without interrupting the debug builds the core of the current process

(GDB) Gcore

Saved Corefile core.3194 #3194就是当前进程的进程号PID

Method 3) A valid Core-size maximum limit value has been set

When the process runs itself out of the problem itself, when the core file such as core.<pid> is automatically generated, file core.* can find all the core files in the current PWD.

< finish >

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.