System settings
If you want the system to generate a core file when an error occurs due to signal interruption, you need to set it in shell as follows:
# Set the core size to unlimited
Ulimit-c unlimited
# Set the file size to unlimited
Ulimit unlimited
Modify the. bashrc file of the current user and add ulimit-c unlimited
Debug with GDB + CORE:
After a core dump occurs, use gdb to view the content of the core file to locate the line that causes the core dump in the file.
Gdb [exec file] [core file]
For example:
Gdb./test. core
You can use where or bt (breaktrace) to view the location and stack of an error.
In gdb debugging, you can also use the following commands to assist in debugging:
Search fun_name lookup Function
B fun_name sets a breakpoint in this function
B file. c 114 sets a breakpoint in row 114 of file. c.
Info break or info B to view the current breakpoint settings
Run the program
File: loads binary files.
N. Execute the next statement.
S one-step execution
C. Continue running
P name print variable
Q exit