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:
$ gdb debugme core
After GDB initializes, the screen should resemble Figure 29-1.
FIGURE 29-1
GDB??™s startup screen
NOTE
802
Programming in Linux Part VI
As you can see near the middle of the figure, GDB displays the name of the executable that created
the core file: ` + ,'. Obviously, the displayed name is wrong; it should be debugme. The odd
characters and the incorrect program name would give an experienced developer an immediate
clue that the program has a significant memory bug. The next line in the figure, the text that reads
Program terminated with signal 11, Segmentation fault, explains why the program
terminated. A segmentation fault occurs anytime a program attempts to access memory that doesn??™t
explicitly belong to it. GDB also helpfully displays the function it was executing,
index_to_the_moon.
If you don??™t like the licensing messages (they annoy me), use the -q (or
--quiet) option when you start GDB to suppress them.
Pages:
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449