The command is, predictably enough,
print. Here are a couple of print commands and their results:
TIP
804
Programming in Linux Part VI
(gdb) print i
$1 = 724
(gdb) print ary[i]
Cannot access memory at address 0xc0000000.
This example continues the earlier examples of debugging debugme.c because you are still trying
to identify where and why debug me crashed. Although in this example, the program crashed at
the point when the counter variable i equaled 724 (the expression $1 refers to an entry in GDB??™s
value history, explained in a moment), where it crashes on your system depends on several variables.
Those variables could include the system??™s memory layout, the process??™s memory space
(especially the kernel??™s stack space), the amount of available memory on your system, and other
factors.
The result of the second command (print ary[i]) makes it pretty clear that the program does
not have access to the memory location specified, although it does have legal access to the preceding
one.
The expression $1 is an alias that refers to an entry in GDB??™s value history. GDB creates value history
entries for each command you type that produces computed results. The alias numbers increment
sequentially each time you execute a command that produces some sort of computed output.
Pages:
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453