GDB Documentation
5.1 Breakpoints, Watchpoints, and Catchpoints
A watchpoint is a special breakpoint that stops your program when the value of an
expression changes. The expression may be a value of a variable, or it could involve values
of one or more variables combined by operators, such as ‘a + b’. This is sometimes called
data breakpoints. You must use a different command to set watchpoints, but aside from that, you can manage a watchpoint
like any other breakpoint: you enable, disable, and delete both breakpoints and watchpoints
using the same commands.
Set a breakpoint on extend_primes(), then enable the watchpoint on n (for writes).