#+SETUPFILE: ~/Dropbox/Doc/Org_Templates/level-1.org
watchpoint
A “watchpoint” is a special breakpoint that stops your program when the value of an expression changes.
watch [-l|-location] EXPR
Set a watchpoint for an expression. GDB will break when the expression EXPR is written into by the program and its value changes.
A simple use of this command:
(gdb) watch foo
Hardware watchpoint 2: foo
The `-location’ argument tells GDB to instead watch the memory referred to by EXPR. In this case, GDB will evaluate EXPR, take the address of the result, and watch the memory at that address. So the following command are equal:
(gdb) watch -location foo
Hardware watchpoint 4: -location foo
(gdb) p &foo
$2 = (int *) 0x7fffffffdde8
(gdb) watch *0x7fffffffdde8
Hardware watchpoint 6: *0x7fffffffdde8
rwatch [-l|-location] EXPR
Set a watchpoint that will break when the value of EXPR is read by the program.
awatch [-l|-location] EXPR
Set a watchpoint that will break when EXPR is either read from or written into by the program.
info watchpoints
Prints a list of watchpoints, using the same format as `info break’ (*note Set Breaks::).
- p/x print in hex
- p/t print in binary