September 2008
Intermediate to advanced
280 pages
6h 31m
English
Our tree example here has greater complexity, and thus, more sophisticated methods are needed. We'll take a look at some here.
In earlier chapters you have used GDB's basic print command. How might you use it here? Well, the main work is obviously done in insert(), so that would be a good place to start. While running GDB within the while loop in that function, you could issue a set of three GDB commands each time you hit a breakpoint:
(gdb) p tmp->val $1 = 12 (gdb) p tmp->left $2 = (struct node *) 0x8049698 (gdb) p tmp->right $3 = (struct node *) 0x0
(Recall from Chapter 1 that the output from GDB is labeled $1, $2, and so on, with these quantities collectively called the value ...
Read now
Unlock full access