How to view the Linux core switch, as well as how to open and close

dump file can be when the program crash, crash program to help us to see the place and context information. In the window, to be able to generate the dump file, you need to write the code yourself. But now the Internet can find the corresponding code, as long as it downloads and then added his own project to go on it! In linux Here's a simple lot. As long as the corresponding switch is opened, linux core will automatically generate the appropriate file when the program crash. Similar dump files in the file and window.
Here are some simple steps:
1. Check whether the current this switch has been opened
by the command: ulimit -c If the output is 0
, it represents not open. If it is unlimited, it has been opened, there is no need to do in the open.
2. Open the command
ulimit -c unlimited. Then 1, can monitor whether or not to open a successful step.
3. If you want to cancel, it is simple: ulimit -c 0 on it
by modifying the above command, usually just work for the current session, when you next log back in, or to re-enter the above command, so a lot of trouble. We can modify
to the / etc / profile file each time the system is automatically opened. Proceed as follows:
1. First, open the / etc / profile file
can generally be found sentence statement in the file: ulimit -S -c 0 / dev / null
2 & 1.ok, according to the above example, we just put that 0 to
unlimited ok. Then save and exit.
2. source / etc / profile so that the current settings to take effect.
3. Has opened by ulimit -c view the next.
In fact, not only this command can be added to the / etc / profile file, others we need every login can join the entry into force of this file, because linux will load the file when you log on. For example, some setting environment variables.
Another method can be set by modifying the file /etc/security/limits.conf, have not tried this method, also see online. But the above two on it!
Finally, talk about generating core
position of the dump file, the default location of the executable program in the same directory, the file name is core. ***, where *** is a number. core
mode dump file name stored in / proc / sys / kernel / core_pattern, the default value is the core. You can change the core by the following command
dump file location (such as hope to the next generation / tmp / cores directory)
echo "/ tmp / cores / core"
/ proc / SYS / Kernel / core_pattern
later we can make setting up the test, write program, an exception. Then see the current directory will have a core * files. Then we can
gdb core. * Program for debugging.

Guess you like

Origin www.cnblogs.com/lee-qi/p/12422235.html