GDB forcibly generates core files

Source: Internet
Author: User

Debugging card dead, sometimes need to kill process restart after the analysis of reasons, this time need to keep the card dead state, generate core files, restart after the analysis.

1, Gcore

Usage:gcore [-o filename] pid

Usage is as follows:

[Root@htdev ~]# gcore 19388 
[thread debugging using libthread_db enabled]
[New Thread 0x2b46ed999890 (LWP 19388)]
[New Thread 0x43e62940 (LWP 19399)]
[New Thread 0x43461940 (LWP 19398)]
[New Thread 0x42a60940 (LWP 19397)]
[New Thread 0x4205f940 (LWP 19396)]
[New Thread 0x41018940 (LWP 19390)]
[New Thread 0x41007940 (LWP 19389)]
0x000000364b4d06d9 in Syscall () from/lib64/libc.so.6
Saved corefile core.19388

2, GDB's Generate-core-file command

[Root@htdev ~]# gdb Attach 19388
or [Root@htdev ~]# gdb-q-19388 GNU gdb Fedora (6.8-37.el5) Copyright (C) 2008 Free Software Foundation, Inc. License GPL  v3+: GNU GPL version 3 or later  

3, modify the build core size

Use Ulimit-a to view the current situation, ulimit-c View only core file size

[Root@htdev ~]# ulimit-a
core file size          (blocks,-c) 0
data seg size           (Kbytes,-D) Unlimited
Scheduli Ng Priority             (-e) 0
file size               (blocks,-f) Unlimited
pending signals (-I                 ) 16383
Max locked Memory       (Kbytes, L)
max memory size         (Kbytes,-m) unlimited
open files                      (-N) 1024
pipe Size            (bytes, p) 8
POSIX message Queues     (bytes,-q) 819200
real-time Priority              (-r) 0
Stack size              (Kbytes,-s) 10240
CPU time               (seconds,-T) unlimited
max User Processes              (-u) 16383< C28/>virtual Memory          (Kbytes,-V) unlimited
file Locks                      (-X) Unlimited
[Root@htdev ~]# ulimit-c
0

Using the ulimit-c filesize command, you can limit the size of the core file (the FileSize unit is KByte). If Ulimit-c Unlimited, the size of the core file is unrestricted. If the generated information exceeds this size, it will be cropped, resulting in an incomplete core file. When debugging this core file, GdB prompts for an error.

[Root@htdev ~]# Ulimit-c Unlimited


4, set the core file path

1. Edit the Environment configuration file, let the shell start automatically set Ulimit
2. Change the core file build path
3.sysctl configuration takes effect
vi/etc/profile
Ulimit-c Unlimited >/dev/null 2>&1
vi/etc/sysctl.conf
kernel.core_uses_pid = 1
kernel.core_pattern=/tmp/core-% e-%p
sysctl-p/etc/sysctl.conf





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.