Watchpoints
A watchpoint is a special kind of breakpoint which, like a normal breakpoint, is an instruction that tells GDB to pause execution of your program. The difference is that watchpoints don't "live" at a line of source code. Instead, a watchpoint is an instruction that tells GDB to pause execution whenever an expression changes value.[11] That expression can be quite simple, like the name of a variable:
(gdb) watch i
which will make GDB pause whenever i
changes value. The expression can also be quite complex:
(gdb) watch (i | j > 12) && i > 24 && strlen(name) > 6
You can think of a watchpoint as being "attached" to an expression; when the value of that expression changes, GDB will pause the program's execution.
Although watchpoints ...
Get The Art of Debugging with GDB, DDD, and Eclipse now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.