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 > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to generate core files and the default core file path under Linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The core file, namely the core file (core file), is a disk file written out by the operating system when the process receives some signals and terminates the process address space and other information about the process status.
1. Set the core file size to list the limits for all resources: ulimit-a
Ulimit-a.png
Or check out core file size: ulimit-c
Core file size: the size of the unlimited:core file is unlimited. 0: the core file will not be generated when the program goes wrong. 1024: if the 1024k core file exceeds this size, it cannot be generated.
Set the core file size: ulimit-c fileSize
Note:
Try to set the file size as large as possible, and the size of the Core file generated when the program crashes is the amount of memory used when the program is running. Take up more memory when stack overflows may occur
two。 Set the name and file path of the core file to the default generation path: enter the default generation name under the same path where the executable file runs the command: default name is core. The new core file overwrites the old core file
a. Set pid as the file extension
1: add pid as the extension, the generated core file name is core.pid 0: do not add pid as the extension, the generated core file name is core modify / proc/sys/kernel/core_uses_pid file content is: 1 modify file command:
Echo "1" > / proc/sys/kernel/core_uses_ pid` * * or * * `sysctl-w kernel.core_uses_pid=1 kernel.core_uses_pid= 1b. Controls where core files are saved and the format of file names
Modify the file command: echo "/ corefile/core-%e-%p-%t" > / proc/sys/kernel/core_pattern or: sysctl-w kernel.core_pattern=/corefile/core.%e.%p.%s.%E can generate the core file to the / corefile directory The resulting file name is core- command name-pid- timestamp the following is a list of parameters:% p-insert pid into filename add pid (process id)% u-insert current uid into filename add current uid (user id)% g-insert current gid into filename add current gid (user group id)% s-insert signal that caused the coredump into the filename add signal resulting in core t-insert UNIX time that the coredump occurred into filename add Unix time% h-insert hostname where the coredump happened into filename when the core file was generated add hostname% e-insert coredumping executable name into filename add the command name that caused the core to be generated
3. Test whether the core file kill-s SIGSEGV $$can be generated to see if the core file is generated in the / corefile directory
If you need to test whether the go program can generate core files, you need to set the environment variable GOTRACEBACK=crash
4. Debug the core file Eg. Test.c
# include int main () {int * p = NULL; * p = 0; return 0;} root@ubuntu:~# gcc-o test test.c`` root@ubuntu:~#. / test``Segmentation fault (core dumped) `* * bingo:** there is a segment error and generate a core file found in the / corefile directory core-test-31421-1476266571 * * start debugging * * `gdb. / test core-test-31421-1476266571 View bug based on stack information
5. Basic GDB commands often need to step through, set breakpoints, and so on, in order to locate problems.
Some common operations of GDB are listed below.
Startup program: run
Set breakpoint: line number b | function name
Delete breakpoint: delete breakpoint number
Disable breakpoints: disable breakpoint number
Enable breakpoints: enable breakpoint number
Step tracking: next (n for short)
Single-step tracking: step (s for short)
Print variable: print variable name (p)
Set variable: set var=value
View variable types: ptype var
Sequential execution to end: cont
Execute sequentially to a line: util lineno
Print stack information: bt
Thank you for reading! On "how to generate core files under Linux, the default core file path" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, you can share it out for more people to see it!
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.