C++ 设置GDB硬件观察点/如何设置软件观察点

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.)

设置can-use-hw-watchpoints

设置是否使用硬件观察点.

显示can-use-hw-watchpoints

显示使用硬件观察点的当前模式.

转载注明原文:C++ 设置GDB硬件观察点/如何设置软件观察点 - 代码日志