In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Preface
Sometimes the program exits abnormally without any log, and the code file can be used for analysis, which records the memory, registers, stack pointers and other information that the program is running.
What is a core file
Usually when we encounter an abnormal exit or termination of a program under Linux, we will use the core file for analysis, which contains the memory, registers, stack pointers and other information when the program is running, in the format of ELF. It can be understood that the current state of the program is dumped into a file. Through the analysis of this file, we can locate the corresponding stack calls and other information when the program exits abnormally or terminates. Provide help to solve the problem.
Debug using core files
Generation method
View the status of the current core file
$ulimit-a.. MMC: core file size (blocks) 0 # closed state.
Turn on the build switch
Ulimit-c unlimitedulimit-a.. Murc: core file size (blocks) unlimited...
Limit the size of the core file (in blocks), usually 1 block=512 bytes. Setting too small may result in no file being generated
$ulimit-c 1024$ ulimit-a. Murray c: core file size (blocks) 1024.
Turn off the build switch
Ulimit-c 0ulimit-a. Murc: core file size (blocks) 0.
The operation on the core file only takes effect for the current time. If you need to take effect permanently, write the corresponding operation to / etc/profile.
Generation path
The core file is generated in the working directory of the program by default, and the generation path can be set to ensure that there is enough space and write permission for the corresponding directory.
Echo / MyCoreDumpDir/core.%e.%p > / proc/sys/kernel/core_pattern
List of parameters used for naming
% p-insert pid into filename # add pid% u-insert current uid into filename # add current uid% g-insert current gid into filename # add current gid% s-insert signal that caused the coredump into the filename # add signal causing core t-insert UNIX time that the coredump occurred into filename # add unix time% h-insert hostname where the coredump happened into filename # add hostname% e-insert coredumping executable name into filename # add command name
If the value of the / proc/sys/kernel/core_uses_pid file is 1, pid will be added to the resulting core file whenever p is configured
Debugging method
You can use gdb to debug core files, and you need to compile with the-g option
$gdb a.out. (gdb) core-file core... (gdb) bt.
If you need to debug the core file generated by the embedded device on PC, you need to select the gdb tool for the corresponding platform and set the location of the symbol file after entering gdb
$xxx-xxx-gdb a.out. (gdb) solib-search-path xxx.so:xxx.so... (gdb) core-file core... (gdb) bt...
Summary
The above is the whole content of this article, I hope that the content of this article has a certain reference and learning value for your study or work, if you have any questions, you can leave a message and exchange, thank you for your support.
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.