|
||||
|
||||
Compile this program using the command gcc -g debugme.c -o debugme. Then, execute the
program using the command./debugme.
$ ./debugme core: ELF 32-big LSB core file Intel 80386, version 1 (SYSV), SVR4-style, SVR4-stylee, from 'debugme' On most systems, when you execute./debugme, it immediately causes a segmentation fault and dumps core, as shown in the output listing. A core dump refers to an application failing and copying all data stored in memory for the application into a file named core in the current directory. That file can be used to help debug a problem with the application. The file output may be called core, or have a numeric extension, such as core.12345 (usually the process ID of the program that died).
If you don't see the core dumped message, try executing the shell command ulimit -c
unlimited, which allows programs to drop a memory dump in their current working directory.
The program has a bug, so you need to debug it. The first step is to start GDB, using the program
name, debugme, and the core file, core, as arguments:
As you can see near the middle of the figure, GDB displays the name of the executable that created
the core file:
TIP
|
||||
|