Resources

GDB tips - Conditional breakpoints

Regexp, temporary and normal breakpoints can all be made conditional by adding the suffix `if [CONDITION]`. Here [CONDITION] is a boolean expression, which, in GDB is true if the result is nonzero, otherwise it is false. The condition can include a function call, the value of a variable or the result of any GDB expression. A common use case is using a conditional breakpoint to pause execution of your program on the [N]th iteration of a loop by typing something like `break foo if i == [N]`. You can also make an existing breakpoint conditional by using the `condition` command. Type `help condition` at the GDB prompt for more.

Check out our other tips and tutorials