设置 GDB 硬件观察点/如何设置软件观察点 [英] Setting GDB hardware watchpoint/how to set software watchpoint

查看:16
本文介绍了设置 GDB 硬件观察点/如何设置软件观察点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个较早的问题解释说,在 x86 上,正在监视的对象的大小受调试寄存器的限制.正如所料,我可以观察"一个双变量.但是我不能看双数据成员,例如,

An earlier question explained that on x86 the size of objects being watched is limited by debug registers. As expected, I can "watch" a double variable. But I can't watch a double datamember, for example,

watch pObject->dPrice

生产

Hardware watchpoint 1: pObject->dPrice

但是当你尝试继续执行时,它会说

But when you try to continue execution, it says

无法插入硬件断点:您可能请求了太多的硬件断点/观察点.

Could not insert hardware breakpoints: You may have requested too many hardware breakpoints/watchpoints.

即使这是唯一断点/观察点.

even though this is the only breakpoint/watchpoint.

我很好奇为什么会这样,但更重要的是有没有办法解决它?根据 GDB 文档,如果它不能使用硬件,它可能会使用软件观察点.在这种情况下,它不会尝试使用软件观察点——有没有办法强制它这样做?

I'm curious why this is so, but more importantly is there a way around it? According to GDB documentation it may use software watchpoints if it can't use hardware. In this case it makes no attempt to use a software watchpoint -- is there a way to force it to do so?

推荐答案

是的,你可以:

设置 can-use-hw-watchpoints 0

set can-use-hw-watchpoints 0

来自5.1.2 设置观察点:

您可以使用 set can-use-hw-watchpoints 0 命令强制 GDB 仅使用软件观察点.将此变量设置为零,GDB 将永远不会尝试使用硬件观察点,即使底层系统支持它们.(请注意,在将 can-use-hw-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.)

设置可以使用的硬件观察点

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

    Set whether or not to use hardware watchpoints.

显示可以使用的硬件观察点

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

    Show the current mode of using hardware watchpoints.

这篇关于设置 GDB 硬件观察点/如何设置软件观察点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆