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 >