我正在 gdb 中调试一个程序,我希望程序在访问内存区域 0x08049000 到 0x0804a000 时停止。当我尝试手动设置内存断点时,gdb 似乎一次不支持两个以上的位置。
(gdb) awatch *0x08049000
Hardware access (read/write) watchpoint 1: *0x08049000
(gdb) awatch *0x08049001
Hardware access (read/write) watchpoint 2: *0x08049001
(gdb) awatch *0x08049002
Hardware access (read/write) watchpoint 3: *0x08049002
(gdb) run
Starting program: /home/iblue/git/some-code/some-executable
Warning:
Could not insert hardware watchpoint 3.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
已经有一个问题被问到了,答案是,有可能用 valgrind 做到这一点。不幸的是,答案不包含任何示例或对 valgrind 手册的参考,所以它不是很启发性:如何使用 gdb 来监视整个内存区域的任何变化?
那么:如何查看整个内存区域?