An earlier question解释说,在 x86 上,正在监视的对象的大小受调试寄存器的限制。正如所料,我可以“观察”一个双变量。但是我不能看双数据成员,例如,
watch pObject->dPrice
生产
Hardware watchpoint 1: pObject->dPrice
但是当你尝试继续执行时,它会说
Could not insert hardware breakpoints: You may have requested too many hardware breakpoints/watchpoints.
即使这是唯一断点/观察点。
我很好奇为什么会这样,但更重要的是有没有办法解决它?根据 GDB 文档,如果它不能使用硬件,它可能会使用软件观察点。在这种情况下,它不会尝试使用软件观察点——有没有办法强制它这样做?
最佳答案
是的,您可以:
set can-use-hw-watchpoints 0
来自 5.1.2 Setting Watchpoints :
You can force GDB to use only software watchpoints with the set can-use-hw-watchpoints 0 command. With this variable set to zero, GDB will never try to use hardware watchpoints, even if the underlying system supports them. (Note that hardware-assisted watchpoints that were set before setting can-use-hw-watchpoints to zero will still use the hardware mechanism of watching expression values.)
设置可以使用的硬件观察点
设置是否使用硬件观察点。
显示可以使用的硬件观察点
显示当前使用硬件观察点的模式。
关于c++ - 设置 GDB 硬件观察点/如何设置软件观察点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3470704/