GDB硬件观察点如何工作?
我对如何实现硬件观察点感兴趣。如果我通过观看uint8_t变量,请手表varname
(观看 - > write Watch),以防将在将检测到的内存位置范围内更改任何数据?
GDB如何处理内存位置/范围?
I am interested in how a hardware watchpoint is realized. If I watch for a uint8_t variable by watch varName
(watch -> write watch) so in case any data is changed on any bit within the range of the memory location it will be detected?
And how is the memory location/range handled by GDB?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在支持硬件观察点的平台上,GDB使用启用它们的处理器功能(du!)。
例如,在x86上,有特殊“ nofollow noreferrer”> debug寄存器停止执行时,当地址总线与给定的地址匹配时,访问是写入(用于观察点),读取(用于实现 access 观察点),等等。
X86处理器不会将单个位写入内存。您至少可以写的是一个字节。编写字节后,处理器将停止(如果调试寄存器已配置如此)。然后,GDB可以将新值与旧值进行比较,如果它们有所不同,请停止执行(否则GDB会吞下观察点并继续没有发生任何事情)。
是的,这可以在单位更改上使用 - 它所需的只是GDB记住旧值(在设置断点时它会这样)。
注意:其中存在一些差距 - 如果内核更改了该值(例如,由于
读取
系统调用),GDB观察点将 not 停止。发生。On platforms which support hardware watchpoints, GDB uses the processor features which enable them (duh!).
For example, on x86, there are special debug registers, which can be programmed to have the processor halt execution when the address bus matches the given address and the access is a write (used for watchpoints), a read (used to implement access watchpoints), etc.
The x86 processors do not write single bits into memory. The least you can write is a byte. The processor will stop after writing the byte (if the debug registers are so configured). GDB can then compare the new value with the old one, and if they differ, stop execution (otherwise GDB will swallow the watchpoint and continue as of nothing happened).
Yes, this can work on single-bit changes -- all it requires is for GDB to remember the old value (which it does when you set up the breakpoint).
Note: there are some gaps in this -- if the value is changed by the kernel (e.g. as a result of
read
system call), GDB watchpoint will not stop when that happens.