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

你可能感兴趣的:(list,网络,X86,variables)