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

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

问题描述

先前的问题解释说,在x86上,被监视对象的大小受调试寄存器的限制。正如所料,我可以看一个双重变量。但是我无法看到一个双数据库,例如,

  watch pObject-> dPrice 

产生

 硬件观察点1 :pObject-> dPrice 

但是当您尝试继续执行时,它表示


无法插入硬件断点:$ b​​ $ b您可能请求太多硬件断点/观察点。


,即使这只是断点/观察点。



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

是的,您可以:


set can-use-hw-watchpoints 0


5.1.2设置观察点
$ b


您可以强制GDB仅使用设置了can-use-hw-watchpoints 0命令的软件观察点。如果将此变量设置为零,即使底层系统支持它们,GDB也不会尝试使用硬件观察点。 (请注意,在将can-use-hw-watchpoints设置为零之前设置的硬件辅助观察点仍将使用观察表达式值的硬件机制。)


set can-use-hw-watchpoints



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



show can-use-hw-watchpoints



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

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

produces

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.

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?

解决方案

Yes, you can:

set can-use-hw-watchpoints 0

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

set can-use-hw-watchpoints

    Set whether or not to use hardware watchpoints.

show can-use-hw-watchpoints

    Show the current mode of using hardware watchpoints.

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

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