GDB Tips

#+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::).

print

  • p/x print in hex
  • p/t print in binary

打赏一个呗

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦