![]() |
Chapter 6 | ![]() |
The first pair is 'next' and 'step'. They perform nearly the same function, and that is to single step through your code, rnning one line at a time. The only difference is that if you use 'next', and the next line is a call to another function, that line will be skipped! Generally, people use 'step'. A continuation of the gdbex2 example in section 6.1.4.2 is show below, using both step and next (which don't have any function calls, so act identically):
(gdb) next 32              array[j] = array[j+1]; (gdb) step 33              array[j+1] = temp; (gdb) |
As you can see, it runs just one line and then stops.
The last command you'll want to know is the ever-useful 'finish' command. Finish simply finishes the current function, and if it is to return a value, it places that in a variable for you to use. Here's 'finish' in use (note, that I disabled breakpoint 3 - finish does not skip breakpoints, and I didn't feel like typing 'continue' another 48 times).
(gdb) finish Run till exit from #0 bubblesort (array=0xbffffb28, size=100) at gdbex2.c:31 0x804850e in main (argc=1, argv=0xbffffd04) at gdbex2.c:16 16       bubblesort(array,100); Value returned is $9 = 99 (gdb) |
Not only do you see how bubblesort works, but you can see my sloppy coding style, as I did not explicitly return any specific 'int' value.
![]() |
Index | ![]() |
6.1.4.3 Watchpoints | 6.1.4.5 Altering Data in a Running Program |