GDB - Conditional Breakpoints

From EdWiki

Conditional Breakpoints

  • Just like regular breakpoints, except that you get to specify some criterion that must be met for the breakpoint to trigger. We use the same break command as before:
(gdb) break file1.c:6 if i >= ARRAYSIZE
  • This command sets a breakpoint at line 6 of file file1.c, which triggers only if the variable i is greater than or equal to the size of the array.
  • Conditional breakpoints can most likely avoid all the unnecessary stepping, etc.