Table of Contents

GDB Breakpoints

Breakpoints pause execution so you can inspect state. Set at a line, function, or condition.

(gdb) break main                 # breakpoint at function 'main'
(gdb) break file.c:10            # breakpoint at line 10 in file.c
(gdb) break file.c:10 if x > 5   # conditional: pause only if x > 5
(gdb) info breakpoints           # list all breakpoints
(gdb) delete 1                    # delete breakpoint 1
(gdb) disable 1                   # disable (don't stop, keep it)
(gdb) enable 1                    # enable
(gdb) continue                    # resume from breakpoint

When a breakpoint hits, GDB shows the line and pauses. You can then inspect variables, print expressions, step through code, etc.

Conditional breakpoints are powerful: break file.c:10 if x > 5 pauses only when the condition is true. Avoids stopping hundreds of times if the issue is only when x is large.

Breakpoint numbers start at 1 (shown by info breakpoints). Reference by number to delete, disable, or enable. Temporarily disable instead of delete if you might need the breakpoint later.

Watch points (watch variable) pause when a variable changes value—useful for finding where a variable gets corrupted. Set with watch x (pause when x changes).

Display commands (display x) print a variable every time execution pauses. Useful for monitoring value changes across stepping.

Clear all breakpoints: delete (without arguments).