breakpoint和watchpoint/data breakpoint

breakpoint很容易理解,是程序的断点。在程序某一个地方设置断点,那么程序运行到此处就会暂停。

那么,watchpoint呢?

watchpoint是一种特殊的断点(所以,首先它还是断点)。在breakpoint的wiki中有相关描述:

http://en.wikipedia.org/wiki/Breakpoint

Other kinds of conditions can also be used, such asthe reading, writing, or modification of a specific location in an area of memory. This is often referred to as a conditional breakpoint, a data breakpoint, or a watchpoint.

即:当内存中一个指定的地址被读、写或者修改的时候就暂停的断点,通常称之为:条件断点或数据断点或观察点。

更多信息,可参考网络文章:

watchpoint在gdb中的实现原理

http://hi.baidu.com/zengzhaonong/blog/item/6bcbce133d78470d5baf537c.html

引用如下:

watchpoint可以看成是一种特殊的"断点", 其实现一般需要CPU支持硬件断点, 如果纯软件实现watchpoint, 那好像会很耗CPU.(我没去看gdb的软watchpoint的实现,有时间得去研究下,不过如果让我来实现这个功能,应该是设置watchpoint所在的那个页表为不可读/访问,然后在缺页处理那检测当前的页和地址是否是软设置watchpoint所在的页和watchpoint的地址,如果是,则说明可以假设该watchpoint发生了)
目前支持watchpoint硬件断点的arch有x86,ppc和mips。
如果支持硬件断点,那么可以将监控的操作交给硬件来完成,而gdb这边只要做个简单的逻辑处理就行。
Setting a data watchpoint
There are times when you want to monitor the values of specific variables or expressions in your source code when running an application. You can do this by setting watchpoints.
The following list shows the commands that are specific to data watchpoints.
awatch
Sets a watchpoint for a data symbol. The debugger stops the target when the memory isread or written.
rwatch
Sets a watchpoint for a data symbol. The debugger stops the target when the memory isread.
watch
Sets a watchpoint for a data symbol. The debugger stops the target when the memory iswritten.

————————————————————————————————————————————————————————————————————————————

DataBreakPoint的实现代码???

http://blog.csdn.net/ccanan/article/details/6018931

————————————————————————————————————————————————————————————————————————————

MSDN关于如何设置data breakpoint:

http://msdn.microsoft.com/en-us/library/350dyxd0(v=VS.90).aspx

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值