In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to generate Core Dump system exception information record file in Linux, I believe most people do not know much about it, so share this article for your reference. I hope you will gain a lot after reading this article. Let's learn about it together.
1 what is Core Dump
Core Dump is also called core dump. When an exception occurs while the program is running, the memory data is saved to a file, a process called Core Dump.
2 the role of Core Dump
In the process of development, it is inevitable to encounter abnormal exits in the process of running the program. If you want to locate what went wrong, it is often not enough to rely on the printing of the program's own information (log records). At this time, you need Core Dump files to help.
A complete Core Dump file is actually equivalent to restoring the exception site. Using the Core Dump file, you can view all the information when the program is abnormal, variable value, stack information, memory data, the running location of the program when the exception occurs (and even record the line number of the code), and so on. All the information needed for positioning can be obtained from the Core Dump file, which can effectively improve the positioning efficiency.
3 how to generate Core Dump
3.1 Core Dump file generation switch
The generation of Core Dump files is limited by the Core file size. The default Core file size in Linux is set to zero, that is, no Core Dump files are generated. You can use the ulimit-c command to view the current Core file size limit.
To generate a Core Dump file, simply execute the following command to set the size of the Core file (where the filesize parameter is measured in KByte):
The code is as follows:
Ulimit-c filesize
If you want to set the Core file size to be unlimited (that is, to save the full running memory of the program), execute the following command:
The code is as follows:
Ulimit-c unlimited
3.2 Core Dump filename Settings
The default name of the Core Dump file is core, and the new Core file will overwrite the old one so that we can only see the last Core Dump information. We can distinguish each generated Core Dump file by setting the Core file name template.
The naming rules of Core Dump files are defined in the / proc/sys/kernel/core_pattern file, and preset variables can be added to the rules to better distinguish Core files. The list of supported variables is as follows:
Variable description%% character% p process ID (PID)% u user ID (UID)% g user group ID%s trigger Core Dump signal% t trigger Core Dump time (in seconds, calculated from 1970-01-01 00:00:00)% h host name (hostname can be viewed through the uname command)% e program name (no path information)% E program path name (path / will be! Replace)% limit size value for cCore files (supported after Linux version 2.6.24)
Note: the maximum length of Core Dump filenames is 128 bytes (before Linux 2.6.19, the maximum length was 64 bytes).
For example, you can generate a Core Dump file named core- Program name-process ID- time with the following command:
Echo "core-%e-%p-%t" > / proc/sys/kernel/core_pattern
From Linux version 2.4, a relatively primitive way to set the Core file name is provided. If you directly set the value in the / proc/sys/kernel/core_uses_pid file to 1, the generated Core file name will be automatically suffixed with .pid, that is, the generated file name is in the form of core.PID. Execute the following command to set this value:
The code is as follows:
Echo "1" > / proc/sys/kernel/core_uses_pid
4 how to use Core Dump
Once you have the Core Dump file, you can use GDB to load the analysis and execute the following command (assuming the executable name and path are / home/hutaow/test_dump, and the resulting Core file is named core):
The code is as follows:
Gdb / home/hutaow/test_dump-c core
After the load is complete, you can view the various running information of the program exception in GDB (view variable values, thread information, call stack, disassembly, and so on).
The above is all the contents of the article "how to generate Core Dump system exception information record file in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.