September 2008
Intermediate to advanced
280 pages
6h 31m
English
In addition to the variables you declare in your program, GDB also provides mechanisms for others.
Output values from GDB's print command are labeled $1, $2, and so on, with these quantities collectively being called the value history. They can be used to produce shortcuts in future print commands that you issue.
For instance, consider the bintree example from Our Main Example Code. Part of a GDB session might look like this:
(gdb) p tmp->left
$1 = (struct node *) 0x80496a8
(gdb) p *(tmp->left)
$2 = {val = 5, left = 0x0, right = 0x0}
(gdb) p *$1
$3 = {val = 5, left = 0x0, right = 0x0}What happened here is that after we printed out the value of the pointer tmp->left and found it to be nonzero, ...