Some programs can be compiled, but the Segment fault (Segment error) will occur during running ). this is usually caused by pointer errors. the following is a detailed introduction to the debugging technology of Linux core dump.
1. Linux core dump:
Some programs can be compiled, but Segment fault (Segment error) may occur during runtime. This is usually caused by pointer errors.
However, this does not prompt the file-> line like a compilation error, but does not have any information, making debugging difficult.
2. Linux core dumpgdb:
One way is to use gdb step for further search.
It is feasible to put it in short code, but to let you step into a code of tens of thousands of lines, I think you will hate the programmer name and call it a programmer.
We still have a better solution, which is core file.
3. Linux core dumpulimit:
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
These require the root permission. In ubuntu, you need to re-enter the first command to set the core size to infinite.
4. Use gdb to view the core file in Linux core dump:
Here we can dump the core when an error occurs due to the message number.
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
After entering gdb, run the bt command to check where the program is running and locate the core dump file-> line.
5. How can we avoid the appearance of core files?
If tcsh is used, add a line in. tcshrc as follows:
Limit coredumpsize 0
If bash is used, add (or modify) one in/etc/profile:
Ulimit-c 0