After GDB hits a breakpoint, you'll almost always inspect a variable. If the same breakpoint gets hit repeatedly (as with a breakpoint inside a loop), you'll inspect the same variable repeatedly. Wouldn't it be nice to automate the procedure by telling GDB to automatically perform a set of commands each time it reaches a breakpoint?
In fact, you can do just this with "breakpoint command lists." We'll use GDB's
printf command to illustrate command lists. You haven't been formally introduced to it yet, but
printf basically works the same way in GDB as it does in C, but the parentheses are optional.
You set command lists using the
breakpoint-number is the ...