Core dumps are often used to diagnose or debug errors in Linux or UNIX programs. Core dumps can serve as useful debugging aids for sys admins to find out why Application like Lighttpd, Apache, PHP-CGI or any other program crashed. Many vendors and open source project author requests a core file to troubleshoot a program. A core file is generated when an application program abnormally terminates due to bug, operating system security protection schema, or program simply try to write beyond the area of memory it has allocated, and so on. This article explains how to turn on core file support and track down bugs in programs. Turn On Core File Creation SupportBy default most Linux distributions turn off core file creation (at least this is true for RHEL, CentOS, Fedora and Suse Linux). You need to use the ulimit command to configure core files. See The Current Core File LimitsType the following command: 0 The output 0 (zero) means core file is not created. Change Core File LimitsIn this example, set the size limit of core files to 75000 bytes: HowTo: Enable Core File Dumps For Application Crashes And Segmentation FaultsEdit /etc/profile file and find line that read as follows to make persistent configuration: ulimit -S -c 0 > /dev/null 2>&1 Update it as follows: ulimit -c unlimited >/dev/null 2>&1 Save and close the file. Edit /etc/sysctl.conf, enter: kernel.core_uses_pid = 1 kernel.core_pattern = /tmp/core-%e-%s-%u-%g-%p-%t fs.suid_dumpable = 2 Save and close the file. Where,
Finally, enable debugging for all apps, enter (Redhat and friends specific): How Do I Enable Core Dumping For Specific Deamon?To enable core dumping for specific deamons, add the following line in the /etc/sysconfig/daemon-file file. In this example, edit /etc/init.d/lighttped and add line as follows: DAEMON_COREFILE_LIMIT='unlimited' Please note that DAEMON_COREFILE_LIMIT is Redhat specific, for all other distro add configuration as follows: ulimit -c unlimited >/dev/null 2>&1 echo /tmp/core-%e-%s-%u-%g-%p-%t > /proc/sys/kernel/core_pattern Save and close the file. Restart / reload lighttpd: unlimited Now, you can send core files to vendor or software writes. How Do I Read Core Files?You need use the gdb command as follows: strace commandSystem administrators, diagnosticians and trouble-shooters will find it invaluable for solving problems with programs for which the source is not readily available since they do not need to be recompiled in order to trace them. This is also useful to submit bug reports to open source developers. See how to use the strace command under Linux to debug the problems. Recommended readings:
Stay tunned for gdb tutorial which will explains how to use generated core file to track down problem. |
|
来自: Harrison.Ding > 《Linux》