使用gdb的watch机制
测试代码:https://github.com/honpey/codebox/tree/master/dlink
(gdb) watch *601030
Hardware watchpoint 2: *601030
(gdb) watch *0x601030
Hardware watchpoint 3: *0x601030
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/hon/codebox/dlink/fun
warning: the debug information found in "/lib64/ld-2.23.so" does not match "/lib64/ld-linux-x86-64.so.2" (CRC mismatch).
Breakpoint 1, main () at fun.c:4
4 printf("hello world\n");
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/hon/codebox/dlink/fun
warning: the debug information found in "/lib64/ld-2.23.so" does not match "/lib64/ld-linux-x86-64.so.2" (CRC mismatch).
Breakpoint 1, main () at fun.c:4
4 printf("hello world\n");
(gdb) c
Continuing.
hello world
Hardware watchpoint 3: *0x601030
Old value = 4195910
New value = -138586046
_dl_fixup (l=<optimized out>, reloc_arg=<optimized out>)
at ../elf/dl-runtime.c:149
149 ../elf/dl-runtime.c: 没有那个文件或目录.
(gdb) p/x -138586046
$1 = 0xf7bd5842
(gdb) p sayhello
$2 = {<text variable, no debug info>} 0x7ffff7bd5842 <sayhello>
(gdb)