|
发表于 2003-4-28 08:57:28
|
显示全部楼层
Core files
In order to analyze a core file the following syntax is used: gdb -c (name of core file) (name of binary which core dumped. Example: gdb -c core gdbtest.
The following is the output of gdb when it loads the core file:
bushmaster:~/gdb/c$ gdb -c core gdbtest
GNU gdb 4.17
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i586-slackware-linux"...
Core was generated by `gdbtest'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/libc.so.5...done.
Reading symbols from /lib/ld-linux.so.1...done.
#0 0x80485a1 in B () at gdbtest.c:22
22 *number = NULL;
(gdb)
gdb shows what line of code caused the program to core dump. All the commands shown in the previous section can be used to examine the state of the program when it core dumped.
Forcing a Core Dump
While frequently core dumps happen when least desired, it is possible to force Unix to terminate the process's execution and write it to a core file. To force a foreground process to core dump hold down the control key and press the \ key.
If the process is a background process it can either be brought to the foreground and killed using the procedure mentioned or killed with signal 11 (ie kill -11 processid). |
|