Linux program debugging

Source: Internet
Author: User

Strace-f-o strace.txt/data1/WAF/sbin/nginx-C/data1/WAF/CONF/nginx. conf

If you want the system to generate a core file when an error occurs due to signal interruption, you need to set it in shell as follows:
# Set the core size to unlimited
Ulimit-C Unlimited
# Set the file size to unlimited
Ulimit Unlimited
GDB/data1/WAF/sbin/nginx core.21169

Compile nginx Program-G: generate the debugging symbol information used by the debugging tool (if the compiled program wants to debug, add-g),-o,-O2,-O3: optimizing the compilation connection is faster to execute-O optimization <-O2 optimization <-O3 optimization (if not added, the default value is-O) this is not required for optimization only when your program is determined to be correct and can be released.

Set core dump file directories and naming rules
/Proc/sys/kernel/core_uses_pid can be used to control whether the PID is added as an extension to the file name of the generated core file. If it is added, the file content is 1; otherwise, it is 0.
/Proc/sys/kernel/core_pattern you can set the location or file name of the formatted core file. For example, the original file content is core-% E.
You can modify it as follows:
Echo "/corefile/Core-% E-% P-% t">/proc/sys/kernel/core_pattern
The generated core file is stored in the/corefile directory, and the generated file name is core-command name-PID-timestamp.
The following is a list of parameters:
% 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 added to generate core Signal
% T-insert UNIX time that the coredump occurred into filename UNIX time when the core file is generated
% H-insert hostname where the coredump happened into filename Add the Host Name
% E-insert coredumping executable name into filename add command name

Test to generate a core file: Kill-s SIGSEGV $

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.