First, I would like to pay tribute to the predecessors of GNU.
In Linux, the debugging tool GDB is a powerful debugger. This article describes how to use the core file to record program errors. To use the core function, you must first set it:
Use the ulimit command to view the details as follows:
[Sam @ UFO testc] $ ulimit-
Core File size (blocks,-C) 0
Data seg size (Kbytes,-d) Unlimited
Scheduling Priority (-e) 0
File size (blocks,-f) Unlimited
Pending signals (-I) 16381
Max locked memory (Kbytes,-l) 64
Max memory size (Kbytes,-m) Unlimited
Open File (-N) 1024
Pipe size (512 bytes,-p) 8
POSIX message queues (bytes,-q) 819200
Real-time priority (-R) 0
Stack size (Kbytes,-S) 10240
CPU time (seconds,-T) Unlimited
Max user processes (-u) 1024
Virtual Memory (Kbytes,-v) Unlimited
File locks (-x) Unlimited
Note that the core file size (blocks,-C) is 0. This indicates the length of the file allocated to the core (unit: block. The size of a block must be determined by the system ), if the value is 0, it is not feasible. Modify the value and enter the following command:
Ulimit-C 1024
Then you can use GDB to execute the program compiled as the debug version. After an error occurs in this program, the error information will be saved to a file starting with core by default.
You can perform the following operations:
(1) In GDB, enter the command to continue executing, for example, c s n, and then exit, where it stops due to an error, let's look at the directory where the current debugging program is located, and the corresponding core file is available.
(2) Input generate-core-file in GDB where it is stopped due to an error, and the corresponding core file is generated.
Key steps:
After exiting the debugging environment, if you want to view the error information again, it is time for the core file to become ready. Use GDB debugfilename core .*****
Note: debugfilename must correspond to core. ***** to see the error information. The *** in core. *** is the PID Number of the program during running. In the debugging program, you can use top | pgrep debugfilename to view the corresponding PID Number.