Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the specific use of core files in Linux system

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Linux system core file specific use method is what, for this problem, this article details the corresponding analysis and solution, hoping to help more want to solve this problem of small partners to find a simpler and easier way.

When a program terminates or crashes during execution, the operating system records the memory state of the program at that time and saves it in a file. This behavior is called Core Dump.

What is the core file usually encountered in Linux program abnormal exit or abort, we will use the core file analysis, which contains the program running memory, registers, stack pointers and other information, format ELF, you can understand the current state of the program work dumped into a file, through the tool analysis of this file, we can locate the program abnormal exit or termination of the corresponding stack call and other information, to provide help to solve the problem.

Debug generation methods using core files

View the current core file status

$ ulimit -a ... -c: core file size (blocks) 0 #Close Status... Turn on the generate switch

ulimit -c unlimited ulimit -a ... -c: core file size (blocks) unlimited ... Limit the size of core files in blocks. Generally, 1 block=512 bytes. If it is too small, files may not be generated.

$ ulimit -c 1024 $ ulimit -a ... -c: core file size (blocks) 1024 ... Turn off the generation switch

ulimit -c 0 ulimit -a ... -c: core file size (blocks) 0 ... The above operations on the core file only take effect for the current time. If they need to take effect permanently, write the corresponding operations to/etc/profile.

generation path

core file is generated in the program's working directory by default. You can set the generation path. You need to ensure that there is enough space for the corresponding directory and you have write permission.

echo` `/MyCoreDumpDir/core``.% e.% p > ``/proc/sys/kernel/core_pattern List of parameters used in 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 that caused core %t - insert UNIX time that the coredump occurred into filename #add unix time when core file was generated %h -insert hostname where the coredump happened into filename #add hostname %e - insert coredump executable name into filename #add command name/proc/sys/kernel/core_uses_pid If the value of this file is 1, then %p will be added to the final core file regardless of when it is configured

debugging method

You can use gdb to debug core files, compilation is required 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 of the corresponding platform, and set the position 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 ... About the Linux system core file specific use method is what the answer to the question is shared here, I hope the above content can have some help for everyone, if you still have a lot of doubts not solved, you can pay attention to the industry information channel to learn more about knowledge.

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.

Share To

Development